473,805 Members | 2,119 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Matplotlib axes label

I've been asking this question at the matplotlib user list and never
gotten an answer. I am hoping that there are matplotlib users here
that can help.

My problem with matplotlib's way of handling axes label is illustrated
by this example:

http://www.scipy.org/Cookbook/Matplo...lticoloredLine

Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
-1.0. I really don't like that because when I read values off the
graph, I have to keep reminding myself that the origin is at -1.1.
This may seem trivial but if you have to think, walk, chew gums at the
same time you're reading the graph, it gets annoying - particularly if
you have to read lots of these graphs.

Is there a way to force the label to start at -1.1 instead of -1.0?

Thanks,

Mar 1 '07 #1
5 11923
On Mar 1, 3:10 pm, "John Henry" <john106he...@h otmail.comwrote :
I've been asking this question at the matplotlib user list and never
gotten an answer. I am hoping that there are matplotlib users here
that can help.

My problem with matplotlib's way of handling axes label is illustrated
by this example:

http://www.scipy.org/Cookbook/Matplo...lticoloredLine

Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
-1.0.
(snipped)
Is there a way to force the label to start at -1.1 instead of -1.0?

Thanks,

You can try adjusting the labels and ticks
using matplotlib.tick er.

To the example you cited, one can add

from matplotlib.tick er import MultipleLocator , FormatStrFormat ter

# ...

minorLocator = MultipleLocator (0.1)
minorFormattor = FormatStrFormat ter('%0.1f')
ax.yaxis.set_mi nor_locator(min orLocator)
ax.yaxis.set_mi nor_formatter(m inorFormattor)

show()

--
Hope this helps,
Steven

Mar 2 '07 #2
On Mar 1, 9:53 pm, attn.steven.... @gmail.com wrote:
On Mar 1, 3:10 pm, "John Henry" <john106he...@h otmail.comwrote :
I've been asking this question at the matplotlib user list and never
gotten an answer. I am hoping that there are matplotlib users here
that can help.
My problem with matplotlib's way of handling axes label is illustrated
by this example:
http://www.scipy.org/Cookbook/Matplo...lticoloredLine
Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
-1.0.

(snipped)
Is there a way to force the label to start at -1.1 instead of -1.0?
Thanks,

You can try adjusting the labels and ticks
using matplotlib.tick er.

To the example you cited, one can add

from matplotlib.tick er import MultipleLocator , FormatStrFormat ter

# ...

minorLocator = MultipleLocator (0.1)
minorFormattor = FormatStrFormat ter('%0.1f')
ax.yaxis.set_mi nor_locator(min orLocator)
ax.yaxis.set_mi nor_formatter(m inorFormattor)

show()

--
Hope this helps,
Steven

Thank you for the response. Yes, adding those lines did work.

But what exactly is going on here? Why would adding these two lines
works?

Thanks,

Mar 2 '07 #3
On Mar 1, 10:07 pm, "John Henry" <john106he...@h otmail.comwrote :
On Mar 1, 9:53 pm, attn.steven.... @gmail.com wrote:
On Mar 1, 3:10 pm, "John Henry" <john106he...@h otmail.comwrote :
I've been asking this question at the matplotlib user list and never
gotten an answer. I am hoping that there are matplotlib users here
that can help.
My problem with matplotlib's way of handling axes label is illustrated
by this example:
>http://www.scipy.org/Cookbook/Matplo...lticoloredLine
Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
-1.0.
(snipped)
Is there a way to force the label to start at -1.1 instead of -1.0?
Thanks,
You can try adjusting the labels and ticks
using matplotlib.tick er.
To the example you cited, one can add
from matplotlib.tick er import MultipleLocator , FormatStrFormat ter
# ...
minorLocator = MultipleLocator (0.1)
minorFormattor = FormatStrFormat ter('%0.1f')
ax.yaxis.set_mi nor_locator(min orLocator)
ax.yaxis.set_mi nor_formatter(m inorFormattor)
show()
--
Hope this helps,
Steven

Thank you for the response. Yes, adding those lines did work.

But what exactly is going on here? Why would adding these two lines
works?

Thanks,

Okay, I played with the ticker formater and locator routines.
Unfortunately, it doesn't help. The locator sets the major value and
the formatter determines how the axes label is formatted. It doesn't
gurantee that the first label starts at the origin. Half of my plots
works, and half of them doesn't.

Mar 2 '07 #4
On Mar 2, 7:02 am, "John Henry" <john106he...@h otmail.comwrote :
On Mar 1, 10:07 pm, "John Henry" <john106he...@h otmail.comwrote :
On Mar 1, 9:53 pm, attn.steven.... @gmail.com wrote:
(snipped)
You can try adjusting the labels and ticks
using matplotlib.tick er.
To the example you cited, one can add
from matplotlib.tick er import MultipleLocator , FormatStrFormat ter
# ...
minorLocator = MultipleLocator (0.1)
minorFormattor = FormatStrFormat ter('%0.1f')
ax.yaxis.set_mi nor_locator(min orLocator)
ax.yaxis.set_mi nor_formatter(m inorFormattor)
show()

Thank you for the response. Yes, adding those lines did work.
But what exactly is going on here? Why would adding these two lines
works?
Thanks,

Okay, I played with the ticker formater and locator routines.
Unfortunately, it doesn't help. The locator sets the major value and
the formatter determines how the axes label is formatted. It doesn't
gurantee that the first label starts at the origin. Half of my plots
works, and half of them doesn't.


As default, matplotlib places labels and tick marks
at major ticks. Minor ticks are invisible as
a default.

The lines that I added turned on *minor*
ticks and their labels; I set them to appear
at integer multiples of 0.1 and I
formatted them as floating point numbers.

There's nothing to prevent you from
having minor ticks appear at intervals
that exceed those of major ticks. E.g.,

minorLocator = MultipleLocator (1.1)

# etc.

--
Hope this helps,
Steven

Mar 2 '07 #5
On Mar 2, 7:22 am, attn.steven.... @gmail.com wrote:
On Mar 2, 7:02 am, "John Henry" <john106he...@h otmail.comwrote :
On Mar 1, 10:07 pm, "John Henry" <john106he...@h otmail.comwrote :
On Mar 1, 9:53 pm, attn.steven.... @gmail.com wrote:

(snipped)
You can try adjusting the labels and ticks
using matplotlib.tick er.
To the example you cited, one can add
from matplotlib.tick er import MultipleLocator , FormatStrFormat ter
# ...
minorLocator = MultipleLocator (0.1)
minorFormattor = FormatStrFormat ter('%0.1f')
ax.yaxis.set_mi nor_locator(min orLocator)
ax.yaxis.set_mi nor_formatter(m inorFormattor)
show()
Thank you for the response. Yes, adding those lines did work.
But what exactly is going on here? Why would adding these two lines
works?
Thanks,
Okay, I played with the ticker formater and locator routines.
Unfortunately, it doesn't help. The locator sets the major value and
the formatter determines how the axes label is formatted. It doesn't
gurantee that the first label starts at the origin. Half of my plots
works, and half of them doesn't.

As default, matplotlib places labels and tick marks
at major ticks. Minor ticks are invisible as
a default.

The lines that I added turned on *minor*
ticks and their labels; I set them to appear
at integer multiples of 0.1 and I
formatted them as floating point numbers.

There's nothing to prevent you from
having minor ticks appear at intervals
that exceed those of major ticks. E.g.,

minorLocator = MultipleLocator (1.1)

# etc.

--
Hope this helps,
Steven

Thanks,

Mar 2 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2630
by: John Hunter | last post by:
matplotlib is a 2D plotting library for python. You can use matplotlib interactively from a python shell or IDE, or embed it in GUI applications (WX, GTK, and Tkinter). matplotlib supports many plot types: line plots, bar charts, log plots, images, pseudocolor plots, legends, date plots, finance charts and more. What's new since matplotlib 0.50 This is the first wide release in 5 months and there has been a tremendous amount of...
2
11658
by: Grant Edwards | last post by:
I downloaded examples/contour_demo.py, and it doesn't run. I've searched both the user guide and the Wiki for "contour" and got zero hits. http://matplotlib.sourceforge.net/matplotlib.pylab.html#-contour appears to be a good reference if you already know how to use contour(), but I could glean zero clues from it on how to actually use contour(). For example, it doesn't explain what the actual formats/types of the parameters. It...
0
2603
by: spross | last post by:
hi all i have to use matplotlib on mac os x. on the official site of matplotlib, i found a link to precompiled python packages for mac os x: http://pythonmac.org/packages/py24-fat/index.html so first, i installed python 2.4. that works great! if i type 'python' in the terminal, it loads python 2.4. after that, i loaded and installed the matplotlib package from this
0
3405
by: Soren | last post by:
Hi, I've been trying to embed matplotlib in wxpython. I want to be able to put a figure (axes) in a wx.Panel and place it somewhere in my GUI. The GUI should have other panels with buttons etc. that can control the output on the figure. I've been looking at the examples from the matplotlib website, but can't seem to get it to work.. Does anyone here have experience in embedding matplotlib in wxpython?
4
3356
by: Bill Jackson | last post by:
Hi, I'm having some trouble plotting with the following matplotlibrc: text.usetex : True I tried clearing the cache files under ~/.matplotlib, but this did not help the problem. I'd post on the matplotlib mailing list, but I have a hard enough time browsing sourceforge's achives (frequent internal server errors). Here is some output:
1
4654
by: Eric Holbrook | last post by:
I'm using matplotlib to generate (and save) plots of bandwidth data from simulation logs. Since the simulations are of varying lengths, i need a way to scale the axes so that every 100,000 points on the X-axis are roughly equal to the height of the Y-axis. In other words, if my X data varied from 0 to 575,000, my aspect ratio would be roughly 6:1. If X goes from 200,000 to 400,000, then the aspect ratio should be 2:1. I've looked...
0
1343
by: vvinuv | last post by:
Hi I am writing a small script which will create a mask file interactively. The script is working fine but when I use this in another script which imports pyraf, it seems hanging. I am attaching the script here. could anybody help me? thanks Vinu V The main program: #!/usr/bin/env python from pyraf import iraf from manualmaskfunc1 import * ManualMaskManager('I_EDCSNJ1216453-1201176.fits')
4
9694
by: John Henry | last post by:
Has anybody been able to create an exe of their python applications involving matplotlib using pyinstall (ver 1.3)? I am getting a: RuntimeError: Could not find the matplotlib data files when I attempt to run the exe created. In searching the web, it appears this is an issue when others tried to use py2exe as well. Unfortunately, the few hits I saw doesn't include enough details to inspire me as to what I should be doing in my
9
14688
by: Glenton | last post by:
Hi All I've been knocking my head against this, and wondered if anyone had any insights. I've made a plot with the wonderful matplotlib. I've always found it to work brilliantly, and I've found that even without knowing much about it I can get it to do most of the things I've wanted it to do. Today, I wanted to insert a few arrows onto my graphs to point out some features. They didn't need any text or other annotation. Just the...
0
9718
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.