canvas教程

Python pychart画图几种常见的形式(2)

字号+ 作者:H5之家 来源:H5之家 2017-08-07 13:06 我要评论( )

pie_plot主要是用来画饼图的类。 arrow_style: 箭头的类型. 更多的箭头类型可以参考: #module-arrow center:饼中心的位置 data:数据源 data_col: 数据来自数据源的第几列 label_col:标签来自数据源的第几列 sta

pie_plot主要是用来画饼图的类。
arrow_style: 箭头的类型.
更多的箭头类型可以参考:
#module-arrow
center:饼中心的位置
data:数据源
data_col: 数据来自数据源的第几列
label_col:标签来自数据源的第几列
start_angle:第一项开始画的时候的角度
arc_offsets:一般为一个和data长度相等的数据,分别表示每一项画图距离中心的位置。如果都为0,则每一块之间没有空隙
shadow:表示阴影,如果设置了则在对象的下方设置,偏移位置为X-off, and y-off

4 矩形图:


from pychart import *

data = [ (0, 10, 30, 40, 60), (10, 20, 40, 50, 55), (20, 10, 35, 38, 43),
         (30, 8, 30, 35, 39), (40, 8, 20, 28, 39) ]

ar = area.T(x_axis = axis.X(label="X axis"),
            y_grid_interval = 10, y_grid_style = line_style.white,
            y_axis = axis.Y(label="Y axis"),
            y_grid_over_plot=1, legend = legend.T())

if theme.use_color:
    colors = [ fill_style.darkseagreen, fill_style.white, fill_style.brown ]
else:
    colors = [ fill_style.gray90, fill_style.white, fill_style.gray50 ]
ar.add_plot(range_plot.T(label="foo", data=data, fill_style = colors[0]))
ar.add_plot(range_plot.T(label="bar", data=data, min_col=2, max_col=3,
                         fill_style = colors[1]))
ar.add_plot(range_plot.T(label="baz", data=data, min_col=3, max_col=4,
                         fill_style = colors[2]))
ar.draw()

range_plot 很多参数与其他的类相似,主要有两个比较重要的。
max_col:扫描的时候较高的边界,默认为2。对应的都是y轴的值
min_col:扫描的时候低的边界,默认为1,对应的都是y轴的值
xcol:x轴的数据来源



附: Label式样
    Restrictions: /h, /v, and /a must appear in the beginning of a string.
/add
    Specifies the angle of the text. Parameter dd is a number between -360 to 360. Value 0 means left-to-right text, 90 means bottom-to-up, etc. If you want to print numbers right after an angle specification, put { between the angle and the number. For example, the below code shows string ""100"" at a 60-degree angle.
    "/a60{}100"
/hA:
    Specifies horizontal alignment of the text. A is one of "L" (left alignment), "R" (right alignment), or "C" (center alignment).
/vA:
    Specifies vertical alignment of the text. A is one of "B" (bottom), "T" (top), or "M" (middle).
/T
    : Switch to Times font family.
/H:
    Switch to Helvetica font family.
/C:
    Switch to Courier font family.
/B:
    Switch to Bookman-Demi font family.
/A:
    Switch to AvantGarde-Book font family.
/P:
    Switch to Palatino font family.
/S:
    Switch to Symbol font family.
/F{family}:
    Switch to family font family. The below example draws string "Funny" using ZapfDingbat font (which produces some meaningless output).

    canvas.show(100, 200, "/F{ZapfDingbat}Funny")

    The list of available fonts are the following:

        Bookman-Demi Bookman-Light Courier AvantGarde-Book AvantGarde-Demi Helvetica Helvetica-Narrow Palatino NewCenturySchlbk Times Symbol ZapfChancery-MediumItalic ZapfChancery-Medium-Italic ZapfDingbats
/b:Switch to bold typeface.
/i:Switch to italic typeface.
/o:Switch to oblique typeface.
/dd: Set font size to dd points.

  "/20{}2001 space odyssey!"
/cdd:
    Set gray-scale to 0.dd. Gray-scale of 0 means black, 1 means white.

//, /{, /}:
    Display `/', `}', or `{'.
{ ... }:
    Limit the scope of escape sequences. For example, "{/10{/20Big text} and small text}" will display "Big Text" using a 20-point font, and "and small text" using a 10-point font.
$\backslash$n:





 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • Python之PyChart画图方法

    Python之PyChart画图方法

    2017-07-04 09:05

  • Python实现局域网内屏幕广播的技术要点分析

    Python实现局域网内屏幕广播的技术要点分析

    2017-06-30 15:04

  • Plotting a function graph with JavaScript

    Plotting a function graph with JavaScript

    2017-06-11 12:07

  • GUI的最终选择:Tkinter8 零基础入门学习Python071

    GUI的最终选择:Tkinter8 零基础入门学习Python071

    2017-06-02 10:00

网友点评