python matlibplot中散点图的缩放轴 [英] Scaling axis for a scatter plot in matlibplot in python

查看:251
本文介绍了python matlibplot中散点图的缩放轴的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用matlibplot进行数据可视化。我的绘图共有6502个数据值,并且工作正常,但这些值接近且密集。

I am working with data visualization using matlibplot. My plot has a total of 6502 data values and is working fine, but the values are close and dense.

例如,我的y轴值在3到10之间,我需要清楚地知道它们之间的每个点。即9.2和9.8之类的值应以至少1 = 0.5的比例清楚地区分。
,即所有3,3.5,4,4.5 ... 10,10.5之类的值都在输出图中显示

For example my y axis values ranges between 3 and 10 and I need to get each point between them so clearly. i.e values like 9.2 and 9.8 are to be clearly distinguished with at least a scale of 1=0.5. i.e all values like 3,3.5,4,4.5...10,10.5 are all seen in the output figure

有人可以解释一下可以做到。我厌倦了使用最大值和最小值设置范围。但这没用。我将限制从3.5设置为10.5,但在图中显示的轴的缩放比例为1 = 1,值从4设置为10。

Can some one explain me how it can be done. I tired setting range using max and min values. but it didn't work. I set the limits from 3.5 to 10.5 but in the figure the axes are displayed with scaling of 1=1 and values are from 4 to 10. Please help me fix this issue

预先感谢

到目前为止,这是我的代码

here's my code so far

 import matplotlib.pyplot as plt
 import numpy as np
 import plotly.plotly as py

 c, ec = np.random.rand(2, len(votes), 10)
 fig, ax = plt.subplots()
 plt.ylim(3.5, 10.5)
 plt.grid(True)
 # where votes range from 10-1000000 and rank range from 3.5 to 10
 matplotlib.pyplot.scatter(votes,rank, c=c, edgecolor=ec)
 plot_url = py.plot_mpl(fig, filename='scatter-plot')
 matplotlib.pyplot.show()

我的情节在这里

推荐答案

使用 plt.yticks(np.arange(min,max,step))代替 plt.ylim()

这篇关于python matlibplot中散点图的缩放轴的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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