[Matplotlib-users] Bug in xscale? Or wrong way to plot log x-axis scale with negative values?
Hi all, I'm plotting data which extent, in x, from -1000 to 1000. But I'm only interested in the values between x = -1 and 0. I also want to plot on an x log scale. But since the x-values are negative, I cannot use xscale(log). I can use xscale(symlog) though and this is the behaviour I want. Unfortunately, symlog seems to be broken. I cannot use the linthreshx argument with a value of less then 2 (the default?). But since I'm interested in x values from -1 to 0, I have to use that argument and set it to something like 1e-5 or even smaller. If I set linthreshx to something smaller then 1, the plot breaks. Here is a simple example, taken from http://stackoverflow.com/questions/3305865/what-is-the-difference-between-log-and-symlog import numpy from matplotlib import pyplot # Enable interactive mode pyplot.ion() # Draw the grid lines pyplot.grid(True) # Numbers from -50 to 50, with 0.1 as step xdomain = numpy.arange(-50,50, 0.1) # Plots a simple linear function 'f(x) = x' pyplot.plot(xdomain, xdomain) # Plots 'sin(x)' pyplot.plot(xdomain, numpy.sin(xdomain)) pyplot.xscale('symlog', linthreshx=0.1) The problem seems to be that, on the x-axis, 0 is actually 10^0 = 1, not 0. Putting something smaller then 1 will make the line go back and the axis values are wrong (when hovering with the mouse and getting the x value). I might not be using the right tool though, but how to achieve what I want? I want the x axis to look like: -10^2-10^1-10^0-10^-1-10^-2-10^-3 ... [up to my defined minimum exponent] ... 10^-310^-210^-110^010^1 10^2 Thank you Nicolas -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplotlib plot() zoomout
hello, im currently working on an interface for data analysis based on the matplotlib gui, there is basically some data which i plot with the plot() command and then i read in some datapoints with a self written routine and the mpl_connect() method. right after that the data point gets plotted into the figure and the hole figure gets redrawn with the draw() method everything works fine so far, my only problem is that when the figure gets redrawn, there is a zoom out like when pressing the 'h' button, is there a possibility to avoid this ? the problem is I have a lot of data and a lot to zoom in before selecting a data point, so that means after each data point i have again to zoom into the figure and so on... thks for your help -- View this message in context: http://old.nabble.com/matplotlib-plot%28%29-zoomout-tp31767232p31767232.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Not able to access CSV file:
Hello guys, I was able to plot when I only had 1 column. But now I have a CSV file that has 10,000 rows and 12 columns. I am trying to write a code to plot all these 12 columns into 12 subplots of one graph. Below found is my code for just one column in one csv file. BTW csv2rec does not work in my version of matplotlib. import matplotlib.pyplot as plt import pylab datafile1 = 'ch1_s1_lrr.csv' datafile2 = 'ch1_s1_baf.csv' a1 = pylab.loadtxt(datafile1, comments='#', delimiter=';') b1 = pylab.loadtxt(datafile2, comments='#', delimiter=';') v1 = [0,98760,0,1] v2 = [0,98760,-2,2] plt.figure(1) plt.subplot(2,1,1) print 'loading', datafile1 plt.axis(v2) plt.plot(a1, 'r.') plt.subplot(2,1,2) print 'loading', datafile2 plt.axis(v1) plt.plot(b1, 'b.') plt.show() Now I want to be able to import 12 columns from the same file and plot all the values of the 1st six columns and only the values less then 0.05 for the next six columns. I am a beginner for python and matplotlib and I have never used arrays before so I am stuck at this point for a more than a week. Please help!!! Any help is appreciated. Thank you for your time and valuable suggestion Karthik -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] matplot zoomout/draw()
hello, im currently working on data analysis with matplotlib/numpy/scipy, my programm plots data with plot() and waits for input commands via __call__ with the x key it is possible to save data points and plot them into the figure, the r key can be used to remove points from data/figure,. the programm works quite good so far, except if i want to remove a data point, i turned of self.dataplot.set_autoscale_on(False), to avoid that there is a zoom out when i save/remove data points. the problem is that this just works if i save an new point, if i want to remove a point via r the figure zooms out each time altough the autoscale is on False here a short part of my source code: def __call__(self, event): if event.key == x: self.x.append(event.xdata) self.y.append(event.ydata) self.N = self.N + 1 plt.axvline(event.xdata, ymin=0, ymax=600, linestyle=--) rest = event.xdata % 4.0e-7 index = int((event.xdata-rest)/4.0e-7-1) plt.plot(self.time[index],self.temp[index],'g^') self.history.append(False) if (self.N%2 == 0) and self.N 17: p1, p2 = self.x[len(self.x)-2],self.x[len(self.x)-1] if p1p2: p1, p2 = p2, p1 self.lgdata.append(self.linreg(p1,p2,self.messdaten)) lgx=np.arange(p1-0.001,p2+0.001,0.001) ram=len(self.lgdata)-1 plt.plot(lgx,self.lgdata[ram][0]*lgx+self.lgdata[ram][1],'r-') self.history.append(True) plt.xlabel('N = '+str(self.N)) plt.draw() elif event.key == r: if (self.remove == True) or (self.N16): if self.history[len(self.history)-1]==True: self.lgdata.pop() del self.dataplot.lines[len(self.dataplot.lines)-1] elif self.history[len(self.history)-1]==False: self.x.pop() self.y.pop() self.N = self.N-1 plt.xlabel('N = '+str(self.N)) del self.dataplot.lines[len(self.dataplot.lines)-1] del self.dataplot.lines[len(self.dataplot.lines)-1] self.history.pop() plt.xlabel('N = '+str(self.N)) plt.draw() i hope somebody can help me -- View this message in context: http://old.nabble.com/matplot-zoomout-draw%28%29-tp31769233p31769233.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] Independent Legends
The first argument of the label command is a list of artist to be labeled. And it does not matter whether they are associated with axes or not. What you can do, therefore, is 1) draw something as you want them in the legend 2) remove them from the axes 3) make a legend from these artists. l1, = plt.plot([1,2,3]) l1.remove() plt.legend([l1], [test]) If you know how to create artists w/o using axes method (or. pyplot function), you may do so of course. Regards, -JJ On Thu, Jun 2, 2011 at 3:41 AM, htaunay htau...@gmail.com wrote: Is there anyway to set/create legends independent of what I am plotting? Simply manually create, position and show legends, that not necessarily are directly linked to the graph. To be specific, I am plotting several points, in a scatter form, individually, and depending on the given attributes, I manually set what colour and marker each point will present. My intention is to create legends that specify the categories of my data, in a way that I can manually define what colour/marker they are linked to. Thanks in advance for any help! -- View this message in context: http://old.nabble.com/Independent-Legends-tp31752112p31752112.html Sent from the matplotlib - users mailing list archive at Nabble.com. -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Data protection magic? Nope - It's vRanger. Get your free trial download today. http://p.sf.net/sfu/quest-sfdev2dev ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users -- Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Discover what all the cheering's about. Get your free trial download today. http://p.sf.net/sfu/quest-dev2dev2 ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users