What are the most frequently used tools for Python visualization?

王林
Release: 2023-05-03 16:13:07
forward
928 people have browsed it

Matplotlib

Matplotlib is a drawing library for Python that can draw high-quality line charts, scatter charts, column charts, bar charts, etc. It is also the basis for many other visualization libraries.

import matplotlib.pyplot as plt import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) plt.plot(x, y) plt.show()
Copy after login

Seaborn

Seaborn is a Python data visualization library based on Matplotlib, specially used to draw statistical graphics, such as heat maps, violin plots, line charts with error bars, etc.

import seaborn as sns import pandas as pd df = pd.read_csv('data.csv') sns.boxplot(x='day', y='total_bill', data=df)
Copy after login

Plotly

Plotly is an interactive data visualization library that can draw high-quality line charts, scatter plots, 3D graphics, and more. It supports multiple programming languages such as Python, R, JavaScript, and more.

import plotly.graph_objs as go import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) fig = go.Figure(data=go.Scatter(x=x, y=y)) fig.show()
Copy after login

Bokeh

Bokeh is an interactive data visualization library that also supports multiple programming languages, such as Python, R, JavaScript, and more. It can draw high-quality line charts, scatter charts, column charts, bar charts, and more.

from bokeh.plotting import figure, show import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) p = figure(title='Sine Wave') p.line(x, y, legend_label='Sine') show(p)
Copy after login

Altair

Altair is a Python visualization library based on Vega-Lite that can quickly and easily draw high-quality line charts, scatter plots, histograms, and more.

import altair as alt import pandas as pd df = pd.read_csv('data.csv') alt.Chart(df).mark_bar().encode( x='year', y='sales', color='region' )
Copy after login

ggplot

ggplot is a Python visualization library based on the ggplot2 library in R language, which can draw high-quality scatter plots, histograms, box plots, etc.

from ggplot import * import pandas as pd df = pd.read_csv('data.csv') ggplot(df, aes(x='date', y='value', color='variable')) + \ geom_line() + \ theme_bw()
Copy after login

Holoviews

Holoviews is a Python visualization library that can create interactive data visualizations and supports multiple types of visual graphics, such as line charts, scatter plots, histograms, and heat maps. etc.

import holoviews as hv import numpy as np x = np.linspace(0, 10, 100) y = np.sin(x) hv.extension('bokeh') hv.Curve((x, y))
Copy after login

Plotnine

Plotnine is a visualization library based on Python's ggplot2 library, which can create high-quality data visualization graphics, such as scatter plots, histograms, line graphs, and more.

from plotnine import * import pandas as pd df = pd.read_csv('data.csv') (ggplot(df, aes(x='year', y='sales', fill='region')) + geom_bar(stat='identity', position='dodge'))
Copy after login

Wordcloud

Wordcloud is a Python library for generating word clouds, which can graphically display frequently occurring words in text.

from wordcloud import WordCloud import matplotlib.pyplot as plt text = "Python is a high-level programming language" wordcloud = WordCloud().generate(text) plt.imshow(wordcloud, interpolation='bilinear') plt.axis('off') plt.show()
Copy after login

Networkx

Networkx is a Python library for creating, manipulating, and visualizing complex networks. It supports the creation of many types of network structures, such as directed graphs, undirected graphs, weighted graphs, and more.

import networkx as nx import matplotlib.pyplot as plt G = nx.DiGraph() G.add_edge('A', 'B') G.add_edge('B', 'C') G.add_edge('C', 'D') G.add_edge('D', 'A') pos = nx.spring_layout(G) nx.draw_networkx_nodes(G, pos, node_size=500) nx.draw_networkx_edges(G, pos) nx.draw_networkx_labels(G, pos) plt.axis('off') plt.show()
Copy after login

The above is the detailed content of What are the most frequently used tools for Python visualization?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!