简体   繁体   English

matplotlib中绘图的单轴上的多个刻度定位器

[英]Multiple tick locators on single axis of a plot in matplotlib

I've done some searching around, and cannot easily find a solution this problem. 我做了一些搜索,并不能轻易找到解决这个问题的方法。 Effectively, I want to have multiple tick locators on a single axis such that I can do something like in the plot below. 实际上,我希望在一个轴上有多个刻度定位器,这样我就可以在下面的图中做一些事情。

CMB功率谱

Note how the x-axis starts off logarithmic, but becomes linear once 500 is reached. 注意x轴如何从对数开始,但一旦达到500就变为线性。 I figured one possible solution was to simply divide the data into two portions, plot it on two graphs, each with their own locators, and then put the graphs right next to each other so they're seamless, but that seems very unpythonic. 我认为一种可能的解决方案是简单地将数据分成两部分,将它绘制在两个图形上,每个图形都有自己的定位器,然后将图形放在彼此旁边,这样它们就是无缝的,但这看起来非常单调。 Anyone have a better solution? 谁有更好的解决方案?

I suspect the following URL might be of use: 我怀疑以下网址可能有用:

http://matplotlib.org/examples/axes_grid/parasite_simple2.html (click on the plot to have the python code) http://matplotlib.org/examples/axes_grid/parasite_simple2.html (点击图表获取python代码)

If you need some specialized graphs, it's always a good idea to have a look at the Matplotlib gallery: 如果你需要一些专门的图表,看看Matplotlib画廊总是一个好主意:

http://matplotlib.org/gallery.html http://matplotlib.org/gallery.html

EDIT: It is possible to make custom ticks on the X-axis: 编辑:可以在X轴上自定义刻度:

http://matplotlib.org/examples/ticks_and_spines/ticklabels_demo_rotation.html http://matplotlib.org/examples/ticks_and_spines/ticklabels_demo_rotation.html

您可以通过赫苏斯·托拉多发现这种规模的实现在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM