[gelöst] Matplotlib - Farbrange einstellen

mit matplotlib, NumPy, pandas, SciPy, SymPy und weiteren mathematischen Programmbibliotheken.
Antworten
10211291
User
Beiträge: 25
Registriert: Montag 8. Juli 2019, 10:51
Wohnort: Berlin

Ich möchte bei matplotlib tricontour den Bereich der Farbskala fest einstellen auf 0.1 - 0.4. Wie kann ich das machen?

Ich habe foldenes probiert:
1) vmin=0.13, vmax=0.4
2) plt.clim(0.13,0.4)

Code: Alles auswählen

import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.tri as tri

# Daten einlesen
df = pd.read_csv("data.csv", sep=";")

# x, y, z zuweisen
x = df.iloc[:, 0]
y = df.iloc[:, 1]
z = df.iloc[:, 2]

# figure erzeugen
fig, ax = plt.subplots(nrows=1)

# Kontur erzeugen
ax.tricontour(x, y, z, levels=14, linewidths=0.5, colors='k',vmin=0.13, vmax=0.4) 
# Füllung hinzufügen
cntr2 = ax.tricontourf(x, y, z, levels=14, cmap="RdBu_r",vmin=0.13, vmax=0.4) 
# Colorbar
fig.colorbar(cntr2, ax=ax)
# Punkte
ax.plot(x, y, 'ko', ms=3) 

# Gleiches Seitenverhältnis
plt.gca().set_aspect('equal', adjustable='box')
#plt.clim(0.13,0.4) 
plt.show()

data.csv sieht wie folgt aus:

Code: Alles auswählen

x;y;z
795;2650;0.217
745;2650;0.207
695;2650;0.175
645;2650;0.156
595;2650;0.167
745;2700;0.222
745;2750;0.260
745;2800;0.309
745;2850;0.337
745;2900;0.361
745;2950;0.365
695;2700;0.202
645;2700;0.166
695;2750;0.226
745;2600;0.166
745;2550;0.169
745;2500;0.213
745;2450;0.238
745;2400;0.275
745;2350;0.298
695;2600;0.144
645;2600;0.140
695;2550;0.161
Zuletzt geändert von 10211291 am Montag 13. Dezember 2021, 14:42, insgesamt 1-mal geändert.
10211291
User
Beiträge: 25
Registriert: Montag 8. Juli 2019, 10:51
Wohnort: Berlin

Lösung gefunden: über levels kann man den genauen Vektor vorgeben:

Code: Alles auswählen

levels =[0.1,0.2,0.3,0.4]
Antworten