xticks的AxesSubplot对象的等效函数 [英] Equivalent function for xticks for an AxesSubplot object

查看:80
本文介绍了xticks的AxesSubplot对象的等效函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我尝试使用Axes对象来控制我的matlibplot图形.我没有使用 plt(又名 import matlibplot.pyplot as plt),因为我根据 这个.

So I am trying to use Axes objects to control my matlibplot figure. I am not using plt (aka import matlibplot.pyplot as plt) because I am embedding the figure in my tkinter GUI per this.

但是,我也在图中使用了子图,因此类似于:

However, I am also using subplots in the figure, so something like:

a = f.add_subplot(121)
a2 = f.add_subplot(122)
a.plot(fn2,mag)
a2.bar(range(0,10), magBin, width)

这一切都很好,我可以使用轴属性来控制事物(ieaaxesMethod()),但我想要条形图的字符串标签,根据 这个,见代码.

This is all well and good, I can use the axes properties to control things (i.e. a.axesMethod()), but I want string labels for my bar plots, per this, see code.

我的困境是我不能使用

plt.xticks(ind+width, ('G1', 'G2', 'G3', 'G4', 'G5') )

如示例中所示,因为如果我想将 plt 嵌入到我的 tkinter gui 中,则无法使用它.我只能用 Axes 对象做些什么.我正在尝试使用a2.set_xticks,但这不允许将字符串用作条形图所需的刻度功能.

as in the example, because I cannot use plt if i want to embed it into my tkinter gui. I am limited to what I can do with Axes objects. I am trying to use a2.set_xticks, but this does not allow for the string as ticks functionality I need for my bar chart.

这方面的任何帮助都会很棒!

Any help in this regard would be amazing!

泰勒

推荐答案

您可以改用:

axes.set_xticks(ticks, minor=False)

axes.set_xticklabels(labels, fontdict=None, minor=False)

这篇关于xticks的AxesSubplot对象的等效函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆