Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Python to realize Visualization Line Chart

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report