In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to draw a line chart in Python pyecharts". In daily operation, I believe many people have doubts about how to draw a line chart in Python pyecharts. The editor consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubts about "how to draw a line chart in Python pyecharts". Next, please follow the editor to study!
I. Draw a line chart import seaborn as snsimport numpy as npimport pandas as pdimport matplotlib as mplimport matplotlib.pyplot as plt%matplotlib inlineplt.rcParams ['font.sans-serif'] = [' Microsoft YaHei'] # to display the Chinese label plt.rcParams ['axes.unicode_minus'] = False # to display the negative sign from datetime import datetimeplt.figure (figsize= (16) 10) import pyecharts.options as optsfrom pyecharts.charts import Linefrom pyecharts.faker import Fakerfrom pyecharts.charts import Barimport osfrom pyecharts.options.global_ normally Options import ThemeType# read data cnbodfgbsort=pd.read_csv ("cnbodfgbsort.csv")
The resulting cnbodfgbsort data:
Cnbodfgbsort.PERSONS.tolist () # Y axis. Set _ global_opts (title_opts=opts.TitleOpts (title= "Movie fare and attendance") # title) c.render_notebook () # display
Add minimum and maximum average import pyecharts.options as optsfrom pyecharts.charts import Linefrom pyecharts.faker import Fakerc = (Line (). Add _ xaxis (cnbodfgbsort.TYPE.tolist ()). Add _ yaxis ("ticket price", cnbodfgbsort.PRICE.tolist ()) .add _ yaxis ("person-time", cnbodfgbsort.PERSONS.tolist (), markpoint_opts=opts.MarkPointOpts (data= [opts.MarkPointItem (type_= "max", name= "maximum")) Opts.MarkPointItem (type_= "min", name= "minimum"),]), markline_opts=opts.MarkLineOpts (data= [opts.MarkLineItem (type_= "average", name= "average")),) .set _ global_opts (title_opts=opts.TitleOpts (title= "Movie fare and attendance")) c.render_notebook ()
3. Vertical bar prompt message tooltip_opts=opts.TooltipOpts (trigger= "axis")
Fourth, display the toolbar toolbox_opts=opts.ToolboxOpts (is_show=True)
5. Solid area filling. Set_series_opts (areastyle_opts=opts.AreaStyleOpts (opacity=0.5), # Transparency label_opts=opts.LabelOpts (is_show=False), # whether the label is displayed)
6. Whether to skip null values import pyecharts.options as optsfrom pyecharts.charts import Linefrom pyecharts.faker import Fakery = Faker.values () y [3], y [5] = None, Nonec = (Line () .add _ xaxis (Faker.choose ()) .add _ yaxis ("merchant A", y, is_connect_nones=True) .set _ global_opts (title_opts=opts.TitleOpts (title= "Line- connection empty data")) .render ("line_connect_null.html"))
As shown in the following figure: y [3] and y [5] the data are all null. If it is displayed directly, the chart will make an error.
# use this parameter to skip null values Avoid discounting is_connect_nones=Trueimport pyecharts.options as optsfrom pyecharts.charts import Linefrom pyecharts.faker import Fakery = Faker.values () y [3], y [5] = None, Nonec = (Line () .add _ xaxis (Faker.choose ()) .add _ yaxis ("merchant A", y, is_connect_nones=True) .set _ global_opts (title_opts=opts.TitleOpts (title= "Line- connection empty data")) c.render_notebook ()
7. Smooth is_smooth=True with broken lines
8. Multiple X axes
Refer to the official website: "multiple_x_axes
9. Ladder diagram is_step=True
At this point, the study of "how to draw a line chart with Python pyecharts" 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.