tickValues - return value.

310 views
Skip to first unread message

dondu...@yandex.ru

unread,
May 23, 2013, 11:16:11 PM5/23/13
to pyqt...@googlegroups.com
Hi everybody.

The question is about AxisItem.tickValues.

The returned values, according to documentaion, is this:
[  
    (spacing, [major ticks]), 
    (spacing, [minor ticks]), 
    ... 
]

The sample for it:

[
 (10000.0, [40000.0, 50000.0, 60000.0]), 
 (2000.0, [36000.0, 38000.0, 42000.0, 44000.0, 46000.0, 48000.0, 52000.0, 54000.0, 56000.0, 58000.0])
]


The question is - what is the meaning of 'spacing'? 
Yep, I can see that is is spacing between the ticks. But 
1. 'spacing'  is  redindant.
2. What if 'spacing' is not equal to real difference between neighbour-ticks?
3. What I have to do if difference between neighbour-ticks is not constant? This situation can be, for example, if tick means 1st day in month, anв days in monthes if different. 




Luke Campagnola

unread,
May 24, 2013, 10:43:37 AM5/24/13
to pyqt...@googlegroups.com
On Thu, May 23, 2013 at 11:16 PM, <dondu...@yandex.ru> wrote:
Hi everybody.

The question is about AxisItem.tickValues.

The returned values, according to documentaion, is this:

[  
    (spacing, [major ticks]), 
    (spacing, [minor ticks]), 
    ... 
]

The sample for it:

[
 (10000.0, [40000.0, 50000.0, 60000.0]), 
 (2000.0, [36000.0, 38000.0, 42000.0, 44000.0, 46000.0, 48000.0, 52000.0, 54000.0, 56000.0, 58000.0])
]


The question is - what is the meaning of 'spacing'? 
Yep, I can see that is is spacing between the ticks. But 
1. 'spacing'  is  redindant. 
2. What if 'spacing' is not equal to real difference between neighbour-ticks?

Spacing is used to help the tick string generator decide how many decimal places to print. It is _usually_ redundant, but in some cases there may be irregularly-spaced ticks with an average spacing value, or with spacing=None, as in the case of log-spaced ticks. 
 
3. What I have to do if difference between neighbour-ticks is not constant? This situation can be, for example, if tick means 1st day in month, anв days in monthes if different. 

In this case, an approximate tick spacing should suffice.

It sounds like you are making a date axis; I'd love to see what you come up with! This is an often-requested feature that I haven't had the time to put together. There is a partial solution in the 'customPlot' example, but it does not implement proper tick spacing, as you are attempting.

Luke

dondu...@yandex.ru

unread,
May 26, 2013, 11:52:28 PM5/26/13
to pyqt...@googlegroups.com
Thak you for answer, I understand.

About my date-axis.
Yes, I write the function that works with dates and return ticks. But, there is 2 problems. 
1. I think, it is very slowly and have to be opimized.
2. It use our own date-format(see below) and C++ - functions to convert dates to number and string.

Function returns two set of ticks, big and small, and this format is very good for your object.
It returns beautiful intervals for different ranges.
It operates dates in this format, list with 6 items:
[2012, 12, 13, 23, 59, 59]


пятница, 24 мая 2013 г., 20:43:37 UTC+6 пользователь Luke Campagnola написал:

Blot Romain

unread,
Nov 22, 2013, 11:35:55 AM11/22/13
to pyqt...@googlegroups.com
Hi all,

Same as many other people I guess. I am very interested in plotting timeseries with different tick formats (ex: yy/mm/dd hh:mm ...) Did someone manage to impliment something in pyqtgraph? Maybe a possible workaround? Of couse I could do a custom function but honestly I am not a very good programmer so for sure it will not be very clean.

Thank you.

Romain

Grant R

unread,
Nov 25, 2013, 2:34:40 PM11/25/13
to pyqt...@googlegroups.com
Attached is an implementation which extends Matplotlib's AutoDateLocator (which is good at determining the best frequency) with the use of pandas for generating ticks.  It neglects minor ticks and assumes that times are in US/Eastern, but otherwise is pretty straightforward.  
dateaxis.py

Blot Romain

unread,
Nov 27, 2013, 12:40:33 PM11/27/13
to pyqt...@googlegroups.com
Thanks Grant R

Luke Campagnola

unread,
Dec 1, 2013, 10:56:45 AM12/1/13
to pyqt...@googlegroups.com
On Fri, Nov 22, 2013 at 11:35 AM, Blot Romain <blot....@gmail.com> wrote:
Same as many other people I guess. I am very interested in plotting timeseries with different tick formats (ex: yy/mm/dd hh:mm ...) Did someone manage to impliment something in pyqtgraph? Maybe a possible workaround? Of couse I could do a custom function but honestly I am not a very good programmer so for sure it will not be very clean.

I have been working on a date/time axis item. You can see the latest here: https://github.com/lcampagn/pyqtgraph/tree/date_time_axisitem
It still has several problems to fix, but it is meant to make it easy to specify exactly what format is used at each scale level. Feedback and patches welcome :)

Luke
Reply all
Reply to author
Forward
0 new messages