简体   繁体   English

在python matplotlib中设置颜色条的数值格式

[英]set numerical format of colorbar in python matplotlib

I am trying to set the scale of the numbers of a colorbar in matplotlib. 我正在尝试在matplotlib中设置颜色条的数字比例。 (ie multiply all the values by 0.001), so I can use the label to indicate the scale (ie magnetic field in gaus*10^3) of the values. (即,将所有值乘以0.001),因此我可以使用标签来指示值的比例(即,以高斯* 10 ^ 3为单位的磁场)。 So far, I figured out, that I can set the rotation of the ticklabels via the 到目前为止,我已经知道,可以通过以下方式设置刻度标签的旋转

cbar1.ax.set_xticklabels(cbar1.ax.get_xticklabels(), size = 10, rotation=90)

comand. 命令。 What I want to do now (it is not working, because the get_xticklabels() funktion doesn´t return a list or some integer values): 我现在想做的(它不起作用,因为get_xticklabels()函数没有返回列表或一些整数值):

cbar1.ax.set_xticklabels((cbar1.ax.get_xticklabels()/1000), size = 10, rotation=90)

I think most people do what you're trying to do by scaling the data that they input to their ax.plot function. 我认为大多数人都是通过缩放他们输入到ax.plot函数的数据来完成您正在尝试做的ax.plot For example, if you were doing a scatter plot you would do: 例如,如果要进行散点图,则可以执行以下操作:

ax.scatter(x_data, y_data, c=gaus_data / 1000)

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

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