pyechart__1

import pyecharts.charts as pyec
import pyecharts.options as opts

x=['甲','乙','丙']
y=[300,800,600]
bar=pyec.Bar()
bar.add_xaxis(x)
bar.add_yaxis(series_name='公司A',yaxis_data=y)
bar.render_notebook()

在这里插入图片描述


bar.set_global_opts(title_opts=opts.TitleOpts(title = '比较图'))
bar.render_notebook()

在这里插入图片描述

#增加一个数据系列
y1 = [1200,500,200]
bar.add_yaxis(series_name = '公司B',yaxis_data=y1)
bar.render_notebook()

在这里插入图片描述

#条形图
bar.reversal_axis()
bar.render_notebook()

在这里插入图片描述

x1 = ['2017','2018','2019']
y1 = [300,900,600]
line = pyec.Line()
line.add_xaxis(x1)
line.add_yaxis(series_name = 'A',y_axis = y1)
#bar.set_global_opts(title_opts=opts.TitleOpts(title = '比较图'))
line.render_notebook()

在这里插入图片描述

y2 = [1300,500,900]
line.add_yaxis(series_name='B',y_axis=y2)
line.set_global_opts(title_opts=opts.TitleOpts(title = '比较图'))
line.render_notebook()

在这里插入图片描述

line.set_global_opts(title_opts=opts.TitleOpts(title = 'First'),legend_opts=opts.LegendOpts(is_show = True),tooltip_opts=opts.TooltipOpts(trigger='axis',axis_pointer_type='cross'))

line.render_notebook()

在这里插入图片描述

line.set_global_opts(title_opts=opts.TitleOpts(title = 'First'),legend_opts=opts.LegendOpts(is_show = True),tooltip_opts=opts.TooltipOpts(trigger='axis',axis_pointer_type='cross'),toolbox_opts=opts.ToolboxOpts(is_show = True,orient='horizontal'),datazoom_opts=opts.DataZoomOpts(type_ = 'slider',range_start=(),range_end=2500))
#vertical,竖着放
line.render_notebook()

在这里插入图片描述

line1 = pyec.Line(init_opts=opts.InitOpts(width = '500px',height='300px'))
line1.add_xaxis(x1)
line1.add_yaxis(series_name = "A",y_axis = y1)

line1.render_notebook()

在这里插入图片描述

x_data = ['直接访问','营销推广','博客推广','搜索引擎']
y_data = [830,214,399,1199]

data_pair = list(zip(x_data,y_data))
print(data_pair)
pie = pyec.Pie()
pie.add(series_name = '推广渠道',data_pair = data_pair)
pie.render_notebook()

在这里插入图片描述

pie1 = pyec.Pie()
pie1.add(series_name = '',data_pair = data_pair,radius = ['40%','75%'])
pie1.set_global_opts(title_opts=opts.TitleOpts(title =''))
pie1.render_notebook()

在这里插入图片描述

#散点图
import numpy as np

x = np.linspace(0,10,30)
y1= np.sin(x)
y2 = np.cos(x)

scatter = pyec.Scatter()
scatter.add_xaxis(xaxis_data = x)
scatter.add_yaxis(series_name = '',y_axis = y1,label_opts=opts.LabelOpts(is_show = False))
scatter.render_notebook()

在这里插入图片描述

import this
x = '''
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
'''
y = x.lower()
print(y)
the zen of python, by tim peters

beautiful is better than ugly.
explicit is better than implicit.
simple is better than complex.
complex is better than complicated.
flat is better than nested.
sparse is better than dense.
readability counts.
special cases aren't special enough to break the rules.
although practicality beats purity.
errors should never pass silently.
unless explicitly silenced.
in the face of ambiguity, refuse the temptation to guess.
there should be one-- and preferably only one --obvious way to do it.
although that way may not be obvious at first unless you're dutch.
now is better than never.
although never is often better than *right* now.
if the implementation is hard to explain, it's a bad idea.
if the implementation is easy to explain, it may be a good idea.
namespaces are one honking great idea -- let's do more of those!
y = y.split()
print(y)
['the', 'zen', 'of', 'python,', 'by', 'tim', 'peters', 'beautiful', 'is', 'better', 'than', 'ugly.', 'explicit', 'is', 'better', 'than', 'implicit.', 'simple', 'is', 'better', 'than', 'complex.', 'complex', 'is', 'better', 'than', 'complicated.', 'flat', 'is', 'better', 'than', 'nested.', 'sparse', 'is', 'better', 'than', 'dense.', 'readability', 'counts.', 'special', 'cases', "aren't", 'special', 'enough', 'to', 'break', 'the', 'rules.', 'although', 'practicality', 'beats', 'purity.', 'errors', 'should', 'never', 'pass', 'silently.', 'unless', 'explicitly', 'silenced.', 'in', 'the', 'face', 'of', 'ambiguity,', 'refuse', 'the', 'temptation', 'to', 'guess.', 'there', 'should', 'be', 'one--', 'and', 'preferably', 'only', 'one', '--obvious', 'way', 'to', 'do', 'it.', 'although', 'that', 'way', 'may', 'not', 'be', 'obvious', 'at', 'first', 'unless', "you're", 'dutch.', 'now', 'is', 'better', 'than', 'never.', 'although', 'never', 'is', 'often', 'better', 'than', '*right*', 'now.', 'if', 'the', 'implementation', 'is', 'hard', 'to', 'explain,', "it's", 'a', 'bad', 'idea.', 'if', 'the', 'implementation', 'is', 'easy', 'to', 'explain,', 'it', 'may', 'be', 'a', 'good', 'idea.', 'namespaces', 'are', 'one', 'honking', 'great', 'idea', '--', "let's", 'do', 'more', 'of', 'those!']
d = {}
for i in y:
    d[i] = d.get(i,0) + 1
print(d)
{'the': 6, 'zen': 1, 'of': 3, 'python,': 1, 'by': 1, 'tim': 1, 'peters': 1, 'beautiful': 1, 'is': 10, 'better': 8, 'than': 8, 'ugly.': 1, 'explicit': 1, 'implicit.': 1, 'simple': 1, 'complex.': 1, 'complex': 1, 'complicated.': 1, 'flat': 1, 'nested.': 1, 'sparse': 1, 'dense.': 1, 'readability': 1, 'counts.': 1, 'special': 2, 'cases': 1, "aren't": 1, 'enough': 1, 'to': 5, 'break': 1, 'rules.': 1, 'although': 3, 'practicality': 1, 'beats': 1, 'purity.': 1, 'errors': 1, 'should': 2, 'never': 2, 'pass': 1, 'silently.': 1, 'unless': 2, 'explicitly': 1, 'silenced.': 1, 'in': 1, 'face': 1, 'ambiguity,': 1, 'refuse': 1, 'temptation': 1, 'guess.': 1, 'there': 1, 'be': 3, 'one--': 1, 'and': 1, 'preferably': 1, 'only': 1, 'one': 2, '--obvious': 1, 'way': 2, 'do': 2, 'it.': 1, 'that': 1, 'may': 2, 'not': 1, 'obvious': 1, 'at': 1, 'first': 1, "you're": 1, 'dutch.': 1, 'now': 1, 'never.': 1, 'often': 1, '*right*': 1, 'now.': 1, 'if': 2, 'implementation': 2, 'hard': 1, 'explain,': 2, "it's": 1, 'a': 2, 'bad': 1, 'idea.': 2, 'easy': 1, 'it': 1, 'good': 1, 'namespaces': 1, 'are': 1, 'honking': 1, 'great': 1, 'idea': 1, '--': 1, "let's": 1, 'more': 1, 'those!': 1}
d = list(d.items())
print(d)
[('the', 6), ('zen', 1), ('of', 3), ('python,', 1), ('by', 1), ('tim', 1), ('peters', 1), ('beautiful', 1), ('is', 10), ('better', 8), ('than', 8), ('ugly.', 1), ('explicit', 1), ('implicit.', 1), ('simple', 1), ('complex.', 1), ('complex', 1), ('complicated.', 1), ('flat', 1), ('nested.', 1), ('sparse', 1), ('dense.', 1), ('readability', 1), ('counts.', 1), ('special', 2), ('cases', 1), ("aren't", 1), ('enough', 1), ('to', 5), ('break', 1), ('rules.', 1), ('although', 3), ('practicality', 1), ('beats', 1), ('purity.', 1), ('errors', 1), ('should', 2), ('never', 2), ('pass', 1), ('silently.', 1), ('unless', 2), ('explicitly', 1), ('silenced.', 1), ('in', 1), ('face', 1), ('ambiguity,', 1), ('refuse', 1), ('temptation', 1), ('guess.', 1), ('there', 1), ('be', 3), ('one--', 1), ('and', 1), ('preferably', 1), ('only', 1), ('one', 2), ('--obvious', 1), ('way', 2), ('do', 2), ('it.', 1), ('that', 1), ('may', 2), ('not', 1), ('obvious', 1), ('at', 1), ('first', 1), ("you're", 1), ('dutch.', 1), ('now', 1), ('never.', 1), ('often', 1), ('*right*', 1), ('now.', 1), ('if', 2), ('implementation', 2), ('hard', 1), ('explain,', 2), ("it's", 1), ('a', 2), ('bad', 1), ('idea.', 2), ('easy', 1), ('it', 1), ('good', 1), ('namespaces', 1), ('are', 1), ('honking', 1), ('great', 1), ('idea', 1), ('--', 1), ("let's", 1), ('more', 1), ('those!', 1)]

wordcloud = pyec.WordCloud()
wordcloud.add(series_name = '',data_pair = d)
wordcloud.render_notebook()

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值