Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 从JSON文件在bokeh中创建piechart_Python 3.x_Jupyter Notebook_Data Visualization_Bokeh - Fatal编程技术网

Python 3.x 从JSON文件在bokeh中创建piechart

Python 3.x 从JSON文件在bokeh中创建piechart,python-3.x,jupyter-notebook,data-visualization,bokeh,Python 3.x,Jupyter Notebook,Data Visualization,Bokeh,我需要读取一个JSON数据文件并在上面创建一个图表。我知道我必须使用熊猫数据帧 我的JSON看起来像 [ { "name": "Anand", "task": "development", }, ..... ] 迄今为止的代码 from bokeh.charts import donut,show,output_file from bokeh.charts.utils import df_from_json import

我需要读取一个JSON数据文件并在上面创建一个图表。我知道我必须使用熊猫数据帧

我的JSON看起来像

[    {
       "name": "Anand",
       "task": "development",  
     },  
        .....  
]
迄今为止的代码

from bokeh.charts import donut,show,output_file
from bokeh.charts.utils import df_from_json

import pandas as pd

df=df_from_json('the path of the file')
d= Donut(df,label=['name', 'task'],values='task',text_font_size='8pt')
output_file("donut.html")
show(d)

您可以直接使用
wedge

from math import pi

from bokeh.plotting import figure, output_file, show

p = figure(x_range=(-1.2, 1.2), y_range=(-1.2, 1.2))

p.wedge(x=0 , y=0, radius=1, start_angle=0, end_angle=0.75*pi, color="red")
p.wedge(x=0 , y=0, radius=1, start_angle=0.75*pi, end_angle=1.05*pi, color="blue")
p.wedge(x=0 , y=0, radius=1, start_angle=1.05*pi, end_angle=1.55*pi, color="green")
p.wedge(x=0 , y=0, radius=1, start_angle=1.55*pi, end_angle=2*pi, color="orange")

output_file("foo.html")

show(p)
在这里,我分别调用了
wedge
,但您也可以将所有数据放入数组/列中,并将所有内容传递给单个调用
wedge