Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

python - Hiding Axis Labels

I'm trying to hide the axis labels on the first subplot at 211. I'd like to label the figure, not just a subplot (reference: "Isub Event Characteristics"). How can I control font properties like size, font, color?

f = Figure()

vdsvgsPlot = f.add_subplot(211)
vdsvgsPlot.plot(theLister()[3],theLister()[0])
vdsvgsPlot.plot(theLister()[3],theLister()[1])

isubPlot = f.add_subplot(212)
isubPlot.plot(theLister()[3],theLister()[2])

plotCanvas = FigureCanvasTkAgg(f, master)
toolbar = NavigationToolbar2TkAgg(plotCanvas, master)

plotCanvas.get_tk_widget().pack()

Thank you in advance.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You have several different questions here... Let me break them up a bit...

By "hide the axis labels on the first subplot" do you mean the actual axis labels (which aren't there unless you specify them), the tick labels (i.e. the numbers along the axis), the axis ticks, or all of the above?

If you mean "all of the above", just do ax.xaxis.set_visible(False) and the same for the y-axis. (ax here would be vdsvgsPlot in your example code above)

If you mean the axis tick labels, just set them to [], i.e.: ax.set_xticklabels([]). (and set_yticklabels for the y-axis)

If you mean the axis ticks, you can do something similar: ax.set_xticks([]) and ax.set_yticks([]) which will turn off both the ticks and ticklabels.

As to the second question, use suptitle to title the entire figure. i.e.: fig.suptitle('whatever') (f.suptitle... in your example code above).

As for how to control the font properties, you can either pass various keyword arguments to suptitle (or anything else that creates text on a plot) or set them after you create the text. For example fig.suptitle('This is a title', size=20, horizontalalignment='left', font='Times', color='red')

In general, I would suggest you look through the various user's guide, gallery of examples (all of which have the source code included), the pyplot api docs, and the detailed api docs.

Hope that helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...