我试图复制一张在AmCharts中完成的图表,但到目前为止我很困惑的方式是让传说在外面和底部的情节
现在我正在使用这个django视图来渲染情节
def my_view(request)
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
colors = ["#FF9800", "#00E676", "#03A9F4", "#1A237E", "#AD1457", "#F44336", "#1DE9B6", "#01579B", "#CFD8DC",
"#90A4AE", "#263238", "#B71C1C", "#FFEB3B"]
data=('serv1','Aplicaiones','serv3','serv4','servi5','serv1','serv2','serv3','serv4','servi5',)
datos=[99.3,99,23,100,99.3,99,23,100,99.3,99]
figure=plt.Figure()
pos=np.arange(len(datos))
ax = figure.add_subplot(111)
b=ax.bar(pos, datos,color=colors)
ax.legend(b,data,loc='upper center', bbox_to_anchor=(0,-.05, 1,0), ncol=5,mode="expand")
ax.axis('off') #
response = HttpResponse(content_type='image/png')
figure.bbox_inches='tight'
canvas = FigureCanvas(figure)
canvas.print_png(response)
return response
参数bbox_to_anchor看起来像是要走的路,但是图表有一个限制,标签的结尾太靠近吧了,我的目标是把标签(每个条1个)留给轴描述的空间