python中一个很酷的绘图模块
PyCoolPlot的Python项目详细描述
PyCoolPlot
python中一个很酷的绘图模块
这是什么?
这是python中的绘图模块。
参考号:
要求
- python 3.6.x或更高版本
- matplotlib
- 努比
- 熊猫
下载
手动安装
- 安装python 3.6.x.
- 克隆或下载此存储库作为zip。
- 导入pycoolplot.py
如何使用
示例代码可能有帮助:
导入
如果使用pip安装pycoolplot,则可以如下方式导入它:
from pycoolplot import pycoolplot
水平条形图
您可以绘制一个漂亮的水平条形图,如:
data = [1000, 2000, 10000] index = ["A", "B", "C"] pycoolplot.horizontal_bar(index, data) pycoolplot.plt.show()
您将看到:
1
如果要绘制速率条形图,可以将rate_graph设置为true,如下所示:
data = [1000, 2000, 10000] index = ["A", "B", "C"] pycoolplot.horizontal_bar(index, data, rate_graph=True) pycoolplot.plt.show()
您将看到:
2
线图
您可以绘制一个漂亮的折线图,如:
data2 = [[970, 1010, 1015, 1008], [975, 1020, 1002, 1035], [975, 985, 995, 999]] index2 = ['Toyota', 'VW', 'GM'] columns = [2013, 2014, 2015, 2016] ylabel = "Number" xlabel = "Year" pycoolplot.line_graph(data2, index2, columns, xlabel, ylabel, xtick=1, ytick=25) pycoolplot.plt.show()
您可以获得:
3
如果您想对焦一条线,您可以设置对焦ID,如:
data2 = [[970, 1010, 1015, 1008], [975, 1020, 1002, 1035], [975, 985, 995, 999]] index2 = ['Toyota', 'VW', 'GM'] columns = [2013, 2014, 2015, 2016] ylabel = "Number" xlabel = "Year" focus_id = 1 # the index of focusing line, in this case Toyota=0, VW=1, GM=2 pycoolplot.line_graph(data2, index2, columns, xlabel, ylabel, xtick=1, ytick=25, focus_id=focus_id) pycoolplot.plt.show()
4
时间条形图
您可以绘制一个漂亮的时间序列条形图,如:
data = pycoolplot.np.linspace(450, 990, 12) + \ pycoolplot.np.random.randint(-50, 50, 12) time_index = pycoolplot.pd.date_range('2017/5', periods=12, freq='MS') pycoolplot.time_vertical_bar(data, time_index, xlabel="time", ylabel="MAU") pycoolplot.plt.show()
5
许可证
麻省理工学院