#!/usr/bin/env python#-*-coding:utf-8-*-ImportNumPy as NPImportPandas as PDImportSeaborn as SNS fromSciPyImportStatsImportMatplotlib as MplImportMatplotlib.pyplot as Plt#Heat Map Heatmapnp.random.seed (0) sns.set () Uniform_data= Np.random.rand (3,3)Print(Uniform_data)#vmin=0.3,vmax=0.6, specifying the minimum and maximum values, center can specify intermediate valuesHeatmap = Sns.heatmap (uniform_data,vmin=0.3,vmax=0.6) plt.show ()#read a copy of the dataFlights = Sns.load_dataset ("Flights")Print(Flights.head ()) Flights= Flights.pivot ("Month"," Year","passengers")Print(flights)#a matrix, the number of passengers more and moreAx =Sns.heatmap (flights)#annot=true means to add numbers into the graph, fmt= "D": is a format, if there is no garbled#linewidths: spacing between squaresAx = Sns.heatmap (flights,annot=true,fmt="D", linewidths=.5) plt.show ()#, CMap: PaletteBX = Sns.heatmap (flights,cmap="Ylgnbu") plt.show ()
Heatmap Heat Map