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

  • Home
  • SEARCH
  • 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 516789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:46:03+00:00 2026-05-13T07:46:03+00:00

I have managed to create a 2 axes graph in ReportLab, by overlapping a

  • 0

I have managed to create a 2 axes graph in ReportLab, by overlapping a barchart and linepot. Here is the code for anyone interested in something similar:

from reportlab.graphics.shapes import Drawing,colors
from reportlab.graphics.widgets.markers import makeMarker
from reportlab.graphics.charts.barcharts import VerticalBarChart
from reportlab.graphics.charts.lineplots import LinePlot

drawing = Drawing(400, 200)
data = [(13, 5, 20, 22, 37, 45, 19, 4)
        ]
noOfBars=len(data[0])

bc = VerticalBarChart()
bc.x = 50
bc.y = 50
bc.height = 125
bc.width = 300
bc.data = data

bc.valueAxis.valueMin = 0
bc.valueAxis.valueMax = 50        
bc.categoryAxis.categoryNames = ['Jan-99','Feb-99','Mar-99','Apr-99','May-99','Jun-99','Jul-99','Aug-99']
drawing.add(bc)

data3=[[(0.5, 4), (1.5, 3), (2.5, 4), (3.5, 6), (4.5, 4), (5.5, 2), (6.5, 5), (7.5, 6)]
       ]

lp = LinePlot()
lp.x = bc.x
lp.y = bc.y
lp.height = bc.height
lp.width = bc.width
lp.data = data3
lp.joinedLines = 1
lp.lines[0].symbol = makeMarker('Circle')
lp.lines[0].strokeColor=colors.blue
lp.lineLabelFormat = '%2.0f'
lp.xValueAxis.valueMin = 0
lp.xValueAxis.valueMax = noOfBars
lp.yValueAxis.valueMin = 0
lp.yValueAxis.valueMax = 8
lp.xValueAxis.visible=False
lp.yValueAxis.visible=False #Hide 2nd plot its Yaxis
drawing.add(lp)

y2Axis = YValueAxis()#Replicate 2nd plot Yaxis in the right
y2Axis.setProperties(lp.yValueAxis.getProperties())
y2Axis.setPosition(lp.x+lp.width,lp.y,lp.height)
y2Axis.tickRight=5
y2Axis.tickLeft=0

y2Axis.configure(data3)
y2Axis.visible=True
drawing.add(y2Axis)

renderPDF.drawToFile(drawing, '../tmp/barline.pdf')

The only problem is that the 2nd has labels pointing inside the graph. I would like them to be outside the graph!. I found a property to adjust the ticks (y2Axis.tickRight=5 , y2Axis.tickLeft=0) but the yvalue labels position is yet a mystery!

Thanks in advance

  • 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-13T07:46:03+00:00Added an answer on May 13, 2026 at 7:46 am

    I did this recently. Something like

    y2Axis.labels.dx = 10
    

    should do the trick for you.

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

Sidebar

Ask A Question

Stats

  • Questions 336k
  • Answers 336k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I actually prefer the second option, with the ID column… May 14, 2026 at 3:47 am
  • Editorial Team
    Editorial Team added an answer have you tried adding the correct binding flags for that… May 14, 2026 at 3:47 am
  • Editorial Team
    Editorial Team added an answer You should not be using RenderWindow but RenderTexture if you… May 14, 2026 at 3:47 am

Related Questions

I am trying to create a C# script to login automatically to a website
Let's say I have a resource file which exports mc1 with 4 frames in
I've managed to create a small project in Eclipse using the Spring & BlazeDS
After much help from all my StackOverFlow brethren, I managed to create a C++
I'm trying to create a custom search interface for Apache Solr using Drupal ,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.