Colorbar configurieren

mit matplotlib, NumPy, pandas, SciPy, SymPy und weiteren mathematischen Programmbibliotheken.
Antworten
Sebbastiannn
User
Beiträge: 6
Registriert: Mittwoch 15. Juni 2022, 22:05

Hallo Leute:)

ich habe ein Auswertungsskript geschrieben und ich habe eine kleine Frage bezüglich der ColorMap Settings.
Ich habe sowas wie "clim" gefunden wo man die Colorbar auf meinetwegen -10 und 10 festlegen kann. Allerdings bekomme ich das irgendwie nicht reingebaut:(
Leider kann ich hier keine Bilder hochladen, sondern nur über URL:/ Allerdings ist die Colormap auf -40, 40 festgelegt was übertrieben ist, weiß auch nicht genau warum diese Werte...
Der if Fall ist absolut relevant, da ich bei dem colorschema die 0 bei Weiß brauche.

Wie würdet ihr mit clip oder anders die colormap von -40, 40 auf -10,10 kürzen:)?

Beste Grüße,
Basti


Code: Alles auswählen

	import matplotlib.pyplot as plt
	from matplotlib.figure import Figure
	...
	...
	...
	figure=Figure()
        axes=figure.add_subplot(111)
        if JB_max > abs(JB_min):
            cf=axes.contourf(JB_for_tablearray[0,1:],JB_for_tablearray[1:,0],JB_for_tablearray[1:,1:], vmin=-JB_max)
        else:
            cf=axes.contourf(JB_for_tablearray[0,1:],JB_for_tablearray[1:,0],JB_for_tablearray[1:,1:], vmax=abs(JB_min))
        axes.set_xlabel("Voltage B IBC (R,Z) [V]")
        axes.set_ylabel("Voltage A '2T' (T,R) [V]")
        axes.set_xlim(left = 0)
        axes.set_title("Jb_for_Contour")
        cb=figure.colorbar(cf)
        figure.savefig(Figures_Table +"\\JB_for_Contour.png", dpi = 300)
        plt.clf()
        ....
Sebbastiannn
User
Beiträge: 6
Registriert: Mittwoch 15. Juni 2022, 22:05

Oh sorry alter code ich meinte natürlich der hier:
Und weiß jemand wie man die Daten von von contour exportiert? Habe nur den Befehl collections[].get_path(), leider fkt der nicht so wie ich will, bzw gar nicht :lol:

Code: Alles auswählen

figure=Figure()
        axes=figure.add_subplot(111)
        if JB_max > abs(JB_min):
            cf=axes.pcolor(JB_for_tablearray[0,1:],JB_for_tablearray[1:,0],JB_for_tablearray[1:,1:], cmap=plt.get_cmap("RdBu_r"), vmin=-JB_max)
        else:
            cf=axes.pcolor(JB_for_tablearray[0,1:],JB_for_tablearray[1:,0],JB_for_tablearray[1:,1:], cmap=plt.get_cmap("RdBu_r"), vmax=abs(JB_min))
        axes.contour(JB_for_tablearray[0,1:],JB_for_tablearray[1:,0],JB_for_tablearray[1:,1:], colors='k')
        axes.scatter(v_B_from_PCE_combined_for_max,v_A_from_PCE_combined_for_max, c='#b41f1f')
        axes.set_xlabel("Voltage B IBC (R,Z) [V]")
        axes.set_ylabel("Voltage A '2T' (T,R) [V]")
        axes.set_xlim(left = 0.4)
        axes.set_title("JB_for_PColor")
        figure.colorbar(cf)
        #plt.clim(-10, 10)
        figure.savefig(Figures_Table +"\\JB_for_PColor.png",dpi=300)
        plt.clf()
Antworten