Dec-13-2021, 07:43 PM
(This post was last modified: Dec-13-2021, 07:43 PM by ju21878436312.)
I would like to set the colorbar range, when plotting my data, using tricontour.
What I have tried:
vmin=0.13, vmax=0.4
to enforce min and max, but it did not show any difference.
plt.clim(0.13,0.4)
which creates an error:
What I have tried:
vmin=0.13, vmax=0.4
to enforce min and max, but it did not show any difference.
plt.clim(0.13,0.4)
which creates an error:
RuntimeError: You must first define an image, e.g., with imshowHere is my code, you can find "data.csv" as attachement to this message.
import pandas as pd import matplotlib.pyplot as plt import matplotlib.tri as tri # load data df = pd.read_csv("data.csv", sep=";") # specify x, y, z x = df.iloc[:, 0] y = df.iloc[:, 1] z = df.iloc[:, 2] # create plot fig, ax = plt.subplots(nrows=1) # contoure ax.tricontour(x, y, z, levels=14, linewidths=0.5, colors='k',vmin=0.13, vmax=0.4) # filling cntr2 = ax.tricontourf(x, y, z, levels=14, cmap="RdBu_r",vmin=0.13, vmax=0.4) # colorbar fig.colorbar(cntr2, ax=ax) # dots ax.plot(x, y, 'ko', ms=3) # Equal aspect ratio plt.gca().set_aspect('equal', adjustable='box') # plt.clim(0.13,0.4) plt.show()
Attached Files