473,624 Members | 2,223 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Matplotlib axis control problem

I would like to control the y axis of a plot. The following code does
exactly what I want it to! On my linux computer it sets the y axis
limits to 18.0 minimum, 58.0 maximum, plots some points on y=x, provides
ticks at 20,30,40,50 and horizontal tick lines that intersect the
plotted points.

All very good, but if I change the upper y axis limit to 54.0,
(ax.set_ylim(18 .0, 54.0)), it fails, plotting the ticks at some strange
values.

Ultimately I want to uncomment the set scale to log and use this to
label semi log plots that by default are only labeled on powers of 10.
My data falls within one decade so I don't want the full 10-100 limits.

I'm rather new at matplotlib so if I'm making trivial errors please feel
free to criticize.

Thanks
Dick C

from pylab import *
from matplotlib.tick er import MaxNLocator

x=[10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0]
y=x
figure(1)
ax=subplot(111)
ax.plot(array(x ), array(y), 'x')
#ax.set_yscale( 'log')
ax.set_ylim(18. 0, 58.0)
ax.yaxis.set_ma jor_locator(Max NLocator(5))
ax.set_yticklab els(('10', '20','30','40', '50','60','70', '80','90','100' ))
ax.yaxis.grid(T rue, linestyle='-', which='major')
show()
Oct 16 '07 #1
0 1535

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

Similar topics

5
11766
by: Enigma Curry | last post by:
I'm playing around with matplotlib for the first time. I'm trying to make a very simple histogram of values 1-6 and how many times they occur in a sequence. However, after about an hour of searching I cannot make the histogram stay within the bounds of the grid lines. Here is my example: pylab.grid() x_values= pylab.hist(x_values,6)
2
18880
by: Caleb Hattingh | last post by:
Hi I tried several Google searches to no avail. I read through pretty much most of the online docs at the matplotlib sourceforge site, but didn't find what I was looking for. I went through the axis.py and ticker.py code today, trying to find out how to set the number of points (ticks) on an axis in Matplotlib. I know that something like
0
1236
by: dhn | last post by:
I am trying to automate the generation of scatterplots in matplotlib. The problem of where to put the labels is known as 'point-feature labeling' (a main application is in cartography, where cities and such are known as 'point features'). In general the problem is not easy. Some references: http://www.merl.com/reports/docs/TR96-04.pdf http://www.eecs.harvard.edu/shieber/Biblio/Papers/tog-final.pdf If anyone knows of any canned python...
2
11643
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...
5
11902
by: John Henry | last post by:
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/Matplotlib/MulticoloredLine Notice that the y-axis goes from (-1.1, 1.1) but the first label is at
0
1933
by: Soren | last post by:
Hi, I'm trying to create a small GUI program where I can do plots using Matplotlib. I've been trying to borrow code from the examples at the matplotlib website, but I can't get it to work. I want to be able to create a wx.Panel that contains an axis for plotting. Around it i want other panels containing various settings, buttons etc. to control the plot. So far I can't even get the program to actually show a plot in a panel.
4
3339
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
4638
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
1679
by: =?ISO-8859-1?Q?Fr=E9d=E9ric_Degraeve?= | last post by:
Hi everybody, I've got a problem concerning matplotlib/pylab. I use it to represent curves. I will use these pictures in a report. However, it writes me a string 'date' on the bottom of my x-axis. I use this to produce my date axis (x-axis): mondays = WeekdayLocator(MONDAY) # every monday months = MonthLocator(range(1,13), bymonthday=1) # every month
0
8238
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
8174
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
8680
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
8624
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...
0
8478
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...
0
7164
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5565
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
4176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1485
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.