6

Possible Duplicate:
Plot logarithmic axes with matplotlib in python

I have a 50*1050 matrix in which the dimension 50 represents the frequency and 1050 the time. I tried to plot it using imshow and I get this image:

http://ge.tt/26MVT0S/v/0?c

But i want to highlight the lower frequencies, which means I need to use the logarithmic scale for the y scale. I searched a lot but I didn't find any effective solution yet.

What I need exactly is that the first row of the matrix should occupy the biggest percentage of the image and as the rows increase, the width if the row they occupy in the image should decrease. Any suggestion?

Community
  • 1
  • 1
Mojtaba
  • 249
  • 6
  • 14
  • @djechlin there are already answers to this question in SO. You only need to google matplotlib + log + scale – joaquin Nov 20 '12 at 17:22
  • ax.set_yscale('log') doesn't help me. it just make the y scale logarithmic. Look at this, when i use you command : http://ge.tt/5cAJX0S/v/0?c – Mojtaba Nov 20 '12 at 17:23
  • The links you are reffering me two, doesn't answer my question. the nearest question is this http://stackoverflow.com/questions/1679126/how-to-plot-an-image-with-non-linear-y-axis-with-matplotlib-using-imshow – Mojtaba Nov 20 '12 at 17:26
  • I think we are missing something essential here - you have a matrix of data `A[i,j]`, where the i-index is time, j-index is frequency, but what are the units of `A[i,j]`? Or do you have 50 different plots versus time and you want to highlight some logarithmic difference in their z-values? – Hooked Nov 20 '12 at 18:52
  • I have a [50:1050] matriz. Each element of this matrix represents the magnitude in different frequencies. Look at the images i have attached. I want the yscale be in logarithmic scale. – Mojtaba Nov 20 '12 at 19:44
  • 5
    @joaquin This is falsely marked as duplicate.The OP's question does not refer to xy-plots, but to plotting a function z=f(x,y) with a logarithmic axis in z. – roadrunner66 Apr 20 '16 at 18:08
  • In response to guidelines [here](http://meta.stackoverflow.com/questions/300952/removing-wrong-duplicate-flag-when-there-is-a-correct-duplicate-flag) I am voting to reopen so this can be marked as a duplicate of [this question](http://stackoverflow.com/questions/1679126/how-to-plot-an-image-with-non-linear-y-axis-with-matplotlib-using-imshow). The current duplicate link is to a different question. @roadrunner66 The question clearly indicates he wants to scale the y-axis? Scaling the z-axis is much easier - but also a duplicate. – AnnanFay Jun 01 '16 at 02:46
  • @Annan, you are right, my comment is wrong. He wants to scale the y-axis logarithmically in a z=f(x,y) plot. So it still isn't a duplicate of the question marked as duplicate which is a y=f(x) plot (2D). An `imshow` plot is z=f(x,y) which is what some call 2.5D since it is still a function (only one z for each xy-pair), not depicting arbitrary surfaces or volumes (true 3D). – roadrunner66 Jun 01 '16 at 04:03

1 Answers1

0

Update the axis:

a = list(axis())
a[3] = 10
axis(a)
yscale('log')
mattexx
  • 6,456
  • 3
  • 36
  • 47
  • 2
    I don't know why thet closed this topics. Thank you for the response, but this is not my answer. It doesn't help me, it just change the numbers on the axis, doesn't make any different finally in how the image look like. – Mojtaba Nov 23 '12 at 08:16
  • What does this answer mean? axis() came out of nowhere? Confused at best. – avocado May 10 '21 at 17:39