axis ticks numbers in log mode

151 views
Skip to first unread message

Rajab Legnain

unread,
Nov 23, 2016, 1:53:28 PM11/23/16
to pyqtgraph
Hello All

I have a volts (dB) vs frequency (Hz) . The frequency axis is setup in log mode. The ticks numbers in frequency axis is shown in exponent format (i.e., 1e2, 1e3, 1e4, 1e5, 1e6, 1e7., .ect).
I want to the ticks string to be shown as (100, 1k, 10k 100k, 1M, 10M). I used used setLabel.(units="Hz") but it doesn't work.

how can do this?


Best regards

Rajab Legnain

unread,
Nov 30, 2016, 8:52:04 PM11/30/16
to pyqtgraph
No one wanna help????

Liutauras B

unread,
Dec 5, 2016, 5:15:16 AM12/5/16
to pyqtgraph

 I got exactly the same problem.

Mikhail Terekhov

unread,
Dec 5, 2016, 10:38:09 AM12/5/16
to pyqt...@googlegroups.com

Rajab Legnain

unread,
Dec 8, 2016, 12:36:09 PM12/8/16
to pyqtgraph
Thanks Mike.
I will try using it

Liutauras B

unread,
Jan 1, 2017, 3:40:14 AM1/1/17
to pyqtgraph
I found simple and not very nice soliution

 ticks = [

[(np.log10(0.1), '0.1'), (np.log10(1), '1'), (np.log10(10), '10'), (np.log10(100), '100'), (np.log10(1000), '1k'), (np.log10(10000), '10k'), (np.log10(100000), '100k')],      # This for major ticks

[(np.log10(0.2), '0.2'), (np.log10(0.3), '0.3'), (np.log10(0.4), '0.4'), (np.log10(0.5), '0.5'), (np.log10(0.6), '0.6'), (np.log10(0.7), '0.7'), (np.log10(0.8), '0.8'), (np.log10(0.9), '0.9'),
 (np.log10(2), '2'), (np.log10(3), '3'), (np.log10(4), '4'), (np.log10(5), '5'), (np.log10(6), '6'), (np.log10(7), '7'), (np.log10(8), '8'), (np.log10(9), '9'),
 (np.log10(20), '20'), (np.log10(30), '30'), (np.log10(40), '40'), (np.log10(50), '50'), (np.log10(60), '60'), (np.log10(70), '70'), (np.log10(80), '80'), (np.log10(90), '90'),
 (np.log10(200), '200'), (np.log10(300), '300'), (np.log10(400), '400'), (np.log10(500), '500'), (np.log10(600), '600'), (np.log10(700), '700'), (np.log10(800), '800'), (np.log10(900), '900'),
 (np.log10(2000), '2k'), (np.log10(3000), '3k'), (np.log10(4000), '4k'), (np.log10(5000), '5k'), (np.log10(6000), '6k'), (np.log10(7000), '7k'), (np.log10(8000), '8k'), (np.log10(9000), '9k'),
 (np.log10(12000), '12k'), (np.log10(13000), '13k'), (np.log10(14000), '14k'), (np.log10(15000), '15k'), (np.log10(16000), '16k'), (np.log10(17000), '17k'), (np.log10(18000), '18k'), (np.log10(19000), '19k'),
 (np.log10(20000), '20k'), (np.log10(30000), '30k'), (np.log10(40000), '40k'), (np.log10(50000), '50k'), (np.log10(60000), '60k'), (np.log10(70000), '70k'), (np.log10(80000), '80k'), (np.log10(90000), '90k')],       # and for minor ticks
  ]
self.ui.plt.getAxis('bottom').setTicks(ticks)
####################################################################################################
Later i recalculate np.log10

ticks = [
            [(-1.0, '0.1'), (0.0, '1'), (1.0, '10'), (2.0, '100'), (3.0, '1k'), (4.0, '10k'), (5.0, '100k')],
            [(-0.69897000433601875, '0.2'), (-0.52287874528033762, '0.3'), (-0.3979400086720376, '0.4'), (-0.3010299956639812, '0.5'), (-0.22184874961635637, '0.6'),
             (-0.15490195998574319, '0.7'), (-0.096910013008056392, '0.8'), (-0.045757490560675115, '0.9'), (0.3010299956639812, '2'), (0.47712125471966244, '3'),
             (0.6020599913279624, '4'), (0.69897000433601886, '5'), (0.77815125038364363, '6'), (0.84509804001425681, '7'), (0.90308998699194354, '8'),
             (0.95424250943932487, '9'), (1.3010299956639813, '20'), (1.4771212547196624, '30'), (1.6020599913279625, '40'), (1.6989700043360187, '50'),
             (1.7781512503836436, '60'), (1.8450980400142569, '70'), (1.9030899869919435, '80'), (1.9542425094393248, '90'), (2.3010299956639813, '200'),
             (2.4771212547196626, '300'), (2.6020599913279625, '400'), (2.6989700043360187, '500'), (2.7781512503836434, '600'), (2.8450980400142569, '700'),
             (2.9030899869919438, '800'), (2.9542425094393248, '900'), (3.3010299956639813, '2k'), (3.4771212547196626, '3k'), (3.6020599913279625, '4k'),
             (3.6989700043360187, '5k'), (3.7781512503836439, '6k'), (3.8450980400142569, '7k'), (3.9030899869919438, '8k'), (3.9542425094393248, '9k'),
             (4.3010299956639813, '20k'), (4.4771212547196626, '30k'), (4.6020599913279625, '40k'), (4.6989700043360187, '50k'), (4.7781512503836439, '60k'),
             (4.8450980400142569, '70k'), (4.9030899869919438, '80k'), (4.9542425094393252, '90k')],

        ]
        self.ui.plt.getAxis('bottom').setTicks(ticks)

Rajab Legnain

unread,
Jan 2, 2017, 8:17:06 PM1/2/17
to pyqtgraph
Many thanks.
I will try to improve it
Reply all
Reply to author
Forward
0 new messages