Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6800985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:02:31+00:00 2026-05-26T19:02:31+00:00

I am using reportlab to generate a LinePlot chart. I can’t seem to get

  • 0

I am using reportlab to generate a LinePlot chart. I can’t seem to get non numeric labels for the X axis.
enter image description here

Does anyone have any ideas?

This is my Lineplot chart class (note: im donig some calculations and setup outside this class, but you get the gist

import reportlab
from advisor.charting.Font import Font

from reportlab.lib.colors import Color, HexColor
from reportlab.lib.pagesizes import cm, inch
from reportlab.graphics.charts.legends import Legend
from reportlab.graphics.charts.textlabels import Label
from reportlab.graphics.charts.linecharts import HorizontalLineChart
from reportlab.graphics.charts.lineplots import LinePlot
from reportlab.graphics.shapes import Drawing, String, _DrawingEditorMixin
from reportlab.graphics.widgets.markers import makeMarker


class TacticalAugLineGraph(_DrawingEditorMixin, Drawing):       
    def __init__(self, width=100, height=110, legend=False, *args, **kw):
        apply(Drawing.__init__, (self, width, height) + args, kw)

        chartFont = Font('Gotham-Bold')

        self._add(self, LinePlot(), name='chart', validate=None, desc=None)
        self.chart._inFill = 1
        self.chart.x                = 20
        self.chart.y                = 15
        self.chart.width        = 85
        self.chart.height   = 95

        #self.chart.lineLabelFormat = '%d%%'
        self.chart.yValueAxis.valueMin = 0
        self.chart.yValueAxis.valueMax = 100
        self.chart.yValueAxis.valueStep = 10

    def apply_colors(self, colors):

        self.chart.lines[0].strokeColor = colors[0]
        self.chart.lines[1].strokeColor = colors[1]
        self.chart.lines[2].strokeColor = colors[2]
        self.chart.lines[3].strokeColor = colors[3]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T19:02:32+00:00Added an answer on May 26, 2026 at 7:02 pm

    I produced a simple example that you could test. The result could look like this:
    enter image description here

    #!/usr/bin/python
    from reportlab.graphics.charts.lineplots import LinePlot
    from reportlab.graphics.shapes import Drawing
    from reportlab.lib import colors
    from random import randint
    from datetime import date, timedelta
    
    # Generate some testdata
    data = [
        [(x,randint(90,100)) for x in range(0,2001,100)],
        [(x,randint(30,80)) for x in range(0,2001,100)],
        [(x,randint(5,20)) for x in range(0,2001,100)],
        ]
    
    # Create the drawing and the lineplot
    drawing = Drawing(400, 200)
    lp = LinePlot()
    lp.x = 50
    lp.y = 50
    lp.height = 125
    lp.width = 300
    lp._inFill = 1
    lp.data = data
    for i in range(len(data)):
        lp.lines[i].strokeColor = colors.toColor('hsl(%s,80%%,40%%)'%(i*60))
    
    # Specify where the labels should be
    lp.xValueAxis.valueSteps = [5, 500, 1402, 1988]
    # Create a formatter that takes the value and format it however you like.
    def formatter(val):
        #return val
        #return 'x=%s'%val
        return (date(2010,1,1) + timedelta(val)).strftime('%Y-%m-%d')
    
    # Use the formatter
    lp.xValueAxis.labelTextFormat = formatter
    drawing.add(lp)
    
    from reportlab.graphics import renderPDF
    renderPDF.drawToFile(drawing, 'example.pdf', 'lineplot with dates')
    

    In the formatter there is 2 alternative return statements that you could play with to get a better grip on it.

    Of course if the data on the x-axis is dates to begin with there need not be any formatter, in that case you could just specify where the labels should be (if you are not satisfied with the default positioning).

    The example above borrows the ideas from page 105 in the reportlab documentation.

    Good luck 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m using Reportlab to generate a PDF. Can´t retrieve a photo from a model.
I'm using Reportlab to generate report cards. The report cards are basically one big
I’m using django and reportlab tool generate Dynamic PDF reports. All the data in
I need to generate the form seen here using Python/reportlab. http://www.flickr.com/photos/49740282@N06/4563137758/sizes/o/ I am attempting
I'm using ReportLab to print a chart produced by matplotlib. I'm able to do
Can we create interactive PDF forms using reportlab? That is, a form that takes
Is it possible to generate a PDF file using ReportLab in such a way
I am using reportlab to generate a pdf report automatically from dynamic data. As
I'm generating a bar chart using ReportLab VerticalBarChart. I need one of the bars
I am using ReportLab to generate a pdf dynamically with python. I would like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.