Home > Article > Backend Development > What are the most frequently used tools for Python visualization?
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()
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)
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()
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)
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' )
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()
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))
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'))
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()
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()
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!