[英]How can I set maximum and minimum value in the color scale of contourf ?
How can I set maximum and minimum value in the color scale of contourf of matplotlib? 如何在matplotlib的contourf的色标中设置最大值和最小值?
I explain. 我解释。 I have a set of data and I want to put as maximum in the color scale the 95% percentile of the data.
我有一组数据,我想在颜色范围内将95%的数据放在最大值。
I have tried in this way: 我试过这样的方式:
goh = colors.Normalize(0, perchi)
plt.contourf(x, y, B, norm = goh) #cmap = plt.cm.hot,
plt.colorbar()
plt.show()
but it returns to me a plot with only one color...and also the scale is monochromatic... I want the whole color scale linear but in the range (min, perchi) and not in (min, max). 但是它只返回一个只有一种颜色的情节...而且刻度也是单色的...我希望整个颜色标度线性但在范围内(min,perchi)而不是(min,max)。 I want that the points between perchi and max are shown as if the y have perchi values...
我希望perchi和max之间的点显示为y具有perchi值...
How could I do? 我该怎么办?
to set the maximum and minimum valued you can do something like: 要设置最大值和最小值,您可以执行以下操作:
import matplotlib.pylab as plt
import numpy as np
# Create fake data
B = np.random.uniform(0, 10, size=(100, 100))
plt.contourf(B, vmin=2, vmax=8)
plt.colorbar()
The values outside the range are set to the maximum and minimum. 范围外的值设置为最大值和最小值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.