I've found many examples for this using features like pcolor and clim, but unless I am misusing them, they seem to only want to work for 2 dimensional data with x, y, values.
My data is formatted as follows:
x y z values
Before I get to plotting in the script I am performing an interpolation which gives me newly gridded data, but with no change to the range of values, meaning a single colorbar will suffice between the two figures. This interpolated data is formatted as follows:
xi yi zi interp
The code I am using to plot it is as follows:
fig = plt.figure()
ax = fig.add_subplot(121, projection = '3d')
ax.scatter(xi, yi, zi, c=interp, alpha=0.08, edgecolors='none'
ax=fig.add_subplot(122, projection = '3d')
s = ax.scatter(x, y, z, c=values, alpha=0.3, edgecolors='none'
plt.colorbar(s)
All of this works just fine, however the problem arises when I load in a separate data-set with similar, but not identical range of values. The colorbars between the two data-sets display different ranges which is not ideal to draw comparisons between the two. All I am looking to do is to forcibly set the min (2100) and max (2600) for the colorbar so that I can apply it to any and all data-sets.
Sorry if this is an easy question, but as I said, I can't seem to find a solution that works for 3D data.
Cheers, Vlad.
我认为您正在寻找例如vmin
和vmax
ax.scatter(x, y, z, c=values, alpha=0.3, edgecolors='none',vmin=2100,vmax=2600)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.