Very new to Seaborn...using it in a class and using VSCode to edit notebooks for assignments.
Without uploading a bunch of data here, I have the following code:
myPlot = sns.barplot(dfFrequencies, x="Topic", y="Relative Frequency")
myPlot.set_xticklabels(myPlot.get_xticklabels(), rotation=45)
myPlot.set_title("Pew Poll Responses: Which is Most Meaningful?")
And in VSCode this is the resulting output
So my first question is how can I suppress the circled text?
Later in the same notebook I have the following code:
# Create the requested scatterplot with Mid-Career Year on the x-axis and
# standardized OPS on the y-axis.
# Remember titles and axis labels.
sns.set(rc={"figure.figsize":(10, 6)})
set_style(theme)
myplot = sns.scatterplot(data=dfHofData, x="Midpoint", y="OPS_z")
myPlot.set_title("Standardized OPS by Mid-Career Year")
myPlot.set_xlabel("Mid-Career Year")
myPlot.set_ylabel("Standardized On Base Percentage Plus Slugging (OPS)")
And it produces this plot. Again there is the text from the last set
but in this case none of them set
s have actually done anything. What am I missing?
The call to set_style(theme)
is some code the instructor provided to set the theme to dark mode. For completeness, here it is:
theme = 'darkmode'
def set_style(theme='darkmode'):
if theme == 'darkmode':
sns.set_theme(style='ticks', context='notebook', rc={'axes.facecolor':'black', 'figure.facecolor':'black', 'text.color':'white',
'xtick.color':'white', 'ytick.color':'white', 'axes.labelcolor':'white', 'axes.grid':False, 'axes.edgecolor':'white'})
else:
sns.set_theme(style='ticks', context='notebook')
To supress the output text, either use a ;
at the end of the line, e.g.,
myPlot.set_title("Pew Poll Responses: Which is Most Meaningful?");
or explicitly capture the function output:
_ = myPlot.set_title("Pew Poll Responses: Which is Most Meaningful?")
For your other issue, you are using myPlot
rather than myplot
, i.e., you have a capital P
when you shouldn't.