Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python to realize Visualization Line Chart

Shulou Source: shulou.com Published: 2022-06-01 20:04:11 09月25日 Update

This article mainly introduces "how to use Python to achieve visual line chart". In daily operation, I believe many people have doubts about how to use Python to achieve visual line chart. The editor consulted all kinds of data and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubt of "how to use Python to achieve visual line chart". Next, please follow the editor to study!

1. Use Numpy ndarray as data to pass into ply

Import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed (1000) y = np.random.standard_normal (10) print "y =% s"% yx = range (len (y)) print "x% s"% xplt.plot (y) plt.show ()

two。 Functions that manipulate axes and add grids and labels

Import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed (1000) y = np.random.standard_normal (10) plt.plot (y.cumsum ()) plt.grid (True) # # add grid plt.axis ('tight') # axis adaptation data axis sets axis plt.show ()

3. Plt.xlim and plt.ylim set the minimum and maximum values for each axis

#! / etc/bin/python#coding=utf-8import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed (1000) y = np.random.standard_normal (20) plt.plot (y.cumsum ()) plt.grid (True) # # add lattice plt.xlim (- 1 y.cumsum () 20) plt.ylim (np.min (y.cumsum ())-1, np.max (y.cumsum ()) + 1) plt.show ()

4. Add title and label plt.title, plt.xlabe, plt.ylabel discrete points, lines

#! / etc/bin/python#coding=utf-8import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed (1000) y = np.random.standard_normal (20) plt.figure (figsize= (7Power4)) # canvas size plt.plot (y.cumsum (), 'baked journal LW = 1.5) # Blue line plt.plot (y.cumsum () 'ro') # discrete point plt.grid (True) plt.axis (' tight') plt.xlabel ('index') plt.ylabel (' value') plt.title ('A simple Plot') plt.show ()

At this point, the study of "how to use Python to achieve visual line chart" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Tags: Line graphs visualization coordinates axes learning data more labels help discrete practical maximum minimum next function size article method maximum title Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Microsoft Redmi MySQL vpn