折线图 放大_第二个折线图(Line Plot)的示例代码

d651aa7c408b3cc791a44b20f874f664.png

这个折线图:

  • 不同样式虚线做数据线:chart.lines[i].strokeDashArray

  • 虚线截小段做图例的色块:

LineLegend,legend.colorNamePairs = Auto(obj = chart)

  • y轴将给的数据放大1000倍:chart.yValueAxis.labelTextScale

  • x轴刻度标签旋转90度:chart.xValueAxis.labels.angle

  • 设定x轴上标签的显示格式:

         chart.yValueAxis.labelTextFormat

代码及注释:

# 不同样式的数据折线以及指定坐标轴上标签的数据格式from reportlab.graphics.charts.lineplots import LinePlotfrom reportlab.lib.colors import PCMYKColorfrom reportlab.graphics.charts.legends import LineLegendfrom reportlab.graphics.shapes import Drawing, _DrawingEditorMixin, Linefrom reportlab.lib.validators import Autofrom reportlab.lib.styles import blackfrom reportlab.graphics.charts.axes import XValueAxis, YValueAxis, AdjYValueAxis, NormalDateXValueAxisclass LineChart_DashedLinesNumberFormates(_DrawingEditorMixin,Drawing):    def __init__(self,width=558,height=140,*args,**kw):        Drawing.__init__(self,width,height,*args,**kw)        # 公共变量        fontName = 'Helvetica'      # 字体        strokeWidth = 0.5           # 线宽        dashArray = (0.3,1)         # 虚线样式        lineCap = 1                 # 线头样式:0尖头、1圆头、2方头        overShoot = 7.5             # 超出部分        # 添加折线图表        self._add(self,LinePlot(),name='chart',validate=None,desc=None)        # 设置x坐标轴        self.chart.xValueAxis = NormalDateXValueAxis()        # x轴是个日期轴        self.chart.xValueAxis.labels.fontName       = fontName        # 日期轴上标签字体        self.chart.xValueAxis.lab
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值