Scatter plot with third variable as color | Python Matplotlib
35.7 هزار بار بازدید -
3 سال پیش
-
How to make and customize
How to make and customize a color map and color bar in python
Choosing Colormaps in Matplotlib:
https://matplotlib.org/3.1.0/tutorial...
-------------------------------------------------------------------------------------------------------------------
import matplotlib.pyplot as plt
x = [1,2,3,4,5,6,7,8,9,10,11]
y = [1,1,1,1,1,1,1,1,1,1,1]
colors = [1,2,3,4,5,6,7,8,9,10,100]
plt.scatter(x,y, s=200, c=colors, cmap=plt.cm.get_cmap("cool",5))
cbar = plt.colorbar(orientation="vertical", extend="both",
pad=0.05, shrink=1, aspect=20, format="%.3f")
cbar.set_label(label="Concentrations", size=15)
cbar.set_ticks([0,5,10])
cbar.set_ticklabels(["0 grams","5 million","cats"])
cbar.ax.tick_params(labelsize=15)
plt.clim(0,10)
plt.cm.[TAB]
plt.show()
Choosing Colormaps in Matplotlib:
https://matplotlib.org/3.1.0/tutorial...
-------------------------------------------------------------------------------------------------------------------
import matplotlib.pyplot as plt
x = [1,2,3,4,5,6,7,8,9,10,11]
y = [1,1,1,1,1,1,1,1,1,1,1]
colors = [1,2,3,4,5,6,7,8,9,10,100]
plt.scatter(x,y, s=200, c=colors, cmap=plt.cm.get_cmap("cool",5))
cbar = plt.colorbar(orientation="vertical", extend="both",
pad=0.05, shrink=1, aspect=20, format="%.3f")
cbar.set_label(label="Concentrations", size=15)
cbar.set_ticks([0,5,10])
cbar.set_ticklabels(["0 grams","5 million","cats"])
cbar.ax.tick_params(labelsize=15)
plt.clim(0,10)
plt.cm.[TAB]
plt.show()
3 سال پیش
در تاریخ 1399/12/13 منتشر شده
است.
35,742
بـار بازدید شده