change BarGraphItem axis labels

1,024 views
Skip to first unread message

Pietro

unread,
Mar 5, 2014, 9:51:04 AM3/5/14
to pyqt...@googlegroups.com

Hi,

I would like to make a BarGraphItem plot using text label as ticks for the axis of the graph instead of numbers. but I didn’t understand how can I set my labels.
I saw the AxisItem class, so I can inherit from this class, overwrite the tickStrings method, create an instance but then I don’t understand how/where I can say at the BarGraphItem must use my instance instead of the default one.

Any hint?

Pietro

Luke Campagnola

unread,
Mar 6, 2014, 3:35:39 PM3/6/14
to pyqt...@googlegroups.com
No need to inherit, just use AxisItem.setTicks: 

Example:
    plot.getAxis('bottom').setTicks([[(1, 'one'), (2, 'two')]])

 

Mehul Tikekar

unread,
Apr 9, 2014, 5:56:58 PM4/9/14
to pyqt...@googlegroups.com
Hi,
  I am using this to set the tick strings for the left axis. My strings are long and they get cropped. How do I move the axis position (manually or automatically), so that all the ticks are completely visible?

Luke Campagnola

unread,
Apr 12, 2014, 5:09:43 PM4/12/14
to pyqt...@googlegroups.com
On Wed, Apr 9, 2014 at 5:56 PM, Mehul Tikekar <mehult...@gmail.com> wrote:
Hi,
  I am using this to set the tick strings for the left axis. My strings are long and they get cropped. How do I move the axis position (manually or automatically), so that all the ticks are completely visible?

It's a bug! 
I have just pushed a fix to the develop branch on github. If you want to stay with 0.9.8 for now, then you can use AxisItem.setWidth() to manually expand the text space.
Thanks for the report.

Mehul Tikekar

unread,
Apr 13, 2014, 2:34:28 PM4/13/14
to pyqt...@googlegroups.com

Thanks! I can confirm that the bugfix works for me.
Reply all
Reply to author
Forward
0 new messages