current position：Home>The strongest Python visualization artifact, none of them
The strongest Python visualization artifact, none of them
2022-02-02 02:48:12 【jiejie】
Data analysis is inseparable from data visualization , The one we use most often is pandas,matplotlib,pyecharts Of course, Tableau, See an article about plotly After drawing, I'm also eager to try , After checking the relevant information, I began to try to draw with it .
I tried to make a line chart 、 Scatter and histogram , Import library first ：
from plotly.graph_objs import Scatter,Layout import plotly import plotly.offline as py import numpy as np import plotly.graph_objs as go #setting offilne Offline mode plotly.offline.init_notebook_mode(connected=True) Copy code
The above lines of code mainly refer to some libraries ,plotly There are online and offline modes , Online mode requires an account that can be edited in the cloud . The offline mode I chose ,plotly Set to offline Mode can be directly in notebook It shows .
2. Make a line chart
N = 100 random_x = np.linspace(0,1,N) random_y0 = np.random.randn(N)+5 random_y1 = np.random.randn(N) random_y2 = np.random.randn(N)-5 #Create traces trace0 = go.Scatter( x = random_x, y = random_y0, mode = 'markers', name = 'markers' ) trace1 = go.Scatter( x = random_x, y = random_y1, mode = 'lines+markers', name = 'lines+markers' ) trace2 = go.Scatter( x = random_x, y = random_y2, mode = 'lines', name = 'lines' ) data = [trace0,trace1,trace2] py.iplot(data) Copy code
Broken line diagram
Random setting 4 Parameters , One x The number of axes and three y Random data of the axis , Make three different types of drawings .trace0 yes markers,trace1 yes lines and markers,trace3 yes lines. Then put the three diagrams on data In this list , call py.iplot(data) that will do . The default color of the drawn picture system is also very good-looking ~
3. Make a scatter chart
trace1 = go.Scatter( y = np.random.randn(500), mode = 'markers', marker = dict( size = 16, color = np.random.randn(500), colorscale = 'Viridis', showscale = True ) ) data = [trace1] py.iplot(data) Copy code
hold mode Set to markers It's a scatter plot , then marker Set a set of parameters , For example, the random range of colors , The size of the scatter , And legends and so on .
trace0 = go.Bar( x = ['Jan','Feb','Mar','Apr', 'May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'], y = [20,14,25,16,18,22,19,15,12,16,14,17], name = 'Primary Product', marker=dict( color = 'rgb(49,130,189)' ) ) trace1 = go.Bar( x = ['Jan','Feb','Mar','Apr', 'May','Jun', 'Jul','Aug','Sep','Oct','Nov','Dec'], y = [19,14,22,14,16,19,15,14,10,12,12,16], name = 'Secondary Product', marker=dict( color = 'rgb(204,204,204)' ) ) data = [trace0,trace1] py.iplot(data) Copy code
Histogram is a commonly used graph ,plotly The way we draw the histogram is the same as us pandas The settings inside are a little similar , They intuitively reflect the difference between two productivity in different months .
The drawing above is just plotly The tip of the iceberg , Are some of the most basic uses , It also has many cool uses and graphics , Especially with pandas The picture combined with the drawing is very beautiful . For example, some stocks K Line graph , If you are interested, you can study ~
author[jiejie],Please bring the original link to reprint, thank you.
The sidebar is recommended
- How IOS developers learn Python Programming 22 - Supplement 1
- Python can meet any API you need
- Python 3 process control statement
- The 20th of 120 Python crawlers, 1637. All the way business opportunity network joined in data collection
- Datetime of pandas time series preamble
- How to send payslips in Python
- [Python] closure and scope
- Application of Python Matplotlib color
- leetcode 1627. Graph Connectivity With Threshold （python）
- Python thread 08 uses queues to transform the transfer scenario
guess what you like
Python: simple single player strange game (text)
Daily python, chapter 27, Django template
TCP / UDP communication based on Python socket
Use of pandas timestamp index
leetcode 148. Sort List（python）
Confucius old book network data collection, take one anti three learning crawler, python crawler 120 cases, the 21st case
[HTB] cap (datagram analysis, setuid capability: Python)
How IOS developers learn Python Programming 23 - Supplement 2
How to automatically identify n + 1 queries in Django applications (2)?
Data analysis starts from scratch. Pandas reads HTML pages + data processing and analysis
- 1313. Unzip the coding list (Java / C / C + + / Python / go / trust)
- Python Office - Python edit word
- Collect it quickly so that you can use the 30 Python tips for taking off
- Strange Python strip
- Python crawler actual combat, pyecharts module, python realizes China Metro data visualization
- DOM breakpoint of Python crawler reverse
- Django admin custom field stores links in the database after uploading files to the cloud
- Who has powder? Just climb who! If he has too much powder, climb him! Python multi-threaded collection of 260000 + fan data
- Python Matplotlib drawing streamline diagram
- The game comprehensively "invades" life: Python releases the "cool run +" plan!
- Python crawler notes: use proxy to prevent local IP from being blocked
- Python batch PPT to picture, PDF to picture, word to picture script
- Advanced face detection: use Dlib, opencv and python to detect face markers
- "Python 3 web crawler development practice (Second Edition)" is finally here!!!!
- Python and Bloom filters
- Python - singleton pattern of software design pattern
- Lazy listening network, audio novel category data collection, multi-threaded fast mining cases, 23 of 120 Python crawlers
- Troubleshooting ideas and summary of Django connecting redis cluster
- Python interface automation test framework (tools) -- interface test tool requests
- Implementation of Morse cipher translator using Python program
- [Python] numpy notes
- 24 useful Python tips
- Pandas table beauty skills
- Python tiktok character video, CV2 module, Python implementation
- I used Python to climb my wechat friends. They are like this
- 20000 words take you into the python crawler requests library, the most complete in history!!
- Answer 2: why can you delete the table but not update the data with the same Python code
- [pandas learning notes 02] - advanced usage of data processing
- How to implement association rule algorithm? Python code and powerbi visualization are explained to you in detail (Part 2 - actual combat)
- Python adds list element append() method, extend() method and insert() method [details]
- python wsgi
- Introduction to Python gunicorn
- Python dictionary query key value pair methods and examples
- Opencv Python reads video, processes and saves it frame by frame
- Python learning process and bug
- Imitate the up master and realize a live broadcast room controlled by barrage with Python!
- Essence! Configuration skills of 12 pandas
- [Python automated operation and maintenance road] path inventory
- Daily automatic health punch in (Python + Tencent cloud server)
- [Python] variables, comments, basic data types