Pyplot / Matplotlib:如何实现压缩的y轴 [英] Pyplot / Matplotlib: How to achieve a compressed y-axis

查看:704
本文介绍了Pyplot / Matplotlib:如何实现压缩的y轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用pyplot根据Walter / Lieth的可视化效果创建一个气候记录仪。





I am using pyplot to create a climograph based on the visualization of Walter/Lieth.

Climograph Walter/Lieth

Another Climograph by Walter/Lieth

As you can see on the images (the links above), the right y-axis is compressed starting from the value of 100. Their visual distance gets smaller while their numerical intervals become larger.

I can't figure out how to achieve this in pyplot. I know how to set the tick values to create a custom scale but of course they always are equidistant. As you can see in my plot the plotted space on the right y-axis corresponds to the interval of the values:

Maybe someone could give a hint on how to achieve the effect shown in the two links above.

Cheers!

解决方案

An example for you:

import matplotlib.pyplot as plt
axes = plt.axes()
axes.set_xlim([-10, 10]) #whatever, optional
axes.set_ylim([0, 1.0]) # whatever, optional
axes.set_xticks([-5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5])
axes.set_yticks([0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100,150,200,300])
plt.plot(x, norm.pdf(x)) #random filler
plt.plot(x, norm.pdf(x, 70.0, 0.1)) #another absolutely random filler
plt.show()

My example only shows how you can tweak the Y coordinate ticks, as you wanted to know. Sorry for not being too helpful apparently. I do not understand the downvote at all. There will probably be better answers, I guess.

For actual compression of the samples (data) there are a few ways:

这篇关于Pyplot / Matplotlib:如何实现压缩的y轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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