SourceForge logo
SourceForge logo
Menu

matplotlib-users — Discussion related to using matplotlib

You can subscribe to this list here.

2003 Jan
Feb
Mar
Apr
May
(3)
Jun
Jul
Aug
(12)
Sep
(12)
Oct
(56)
Nov
(65)
Dec
(37)
2004 Jan
(59)
Feb
(78)
Mar
(153)
Apr
(205)
May
(184)
Jun
(123)
Jul
(171)
Aug
(156)
Sep
(190)
Oct
(120)
Nov
(154)
Dec
(223)
2005 Jan
(184)
Feb
(267)
Mar
(214)
Apr
(286)
May
(320)
Jun
(299)
Jul
(348)
Aug
(283)
Sep
(355)
Oct
(293)
Nov
(232)
Dec
(203)
2006 Jan
(352)
Feb
(358)
Mar
(403)
Apr
(313)
May
(165)
Jun
(281)
Jul
(316)
Aug
(228)
Sep
(279)
Oct
(243)
Nov
(315)
Dec
(345)
2007 Jan
(260)
Feb
(323)
Mar
(340)
Apr
(319)
May
(290)
Jun
(296)
Jul
(221)
Aug
(292)
Sep
(242)
Oct
(248)
Nov
(242)
Dec
(332)
2008 Jan
(312)
Feb
(359)
Mar
(454)
Apr
(287)
May
(340)
Jun
(450)
Jul
(403)
Aug
(324)
Sep
(349)
Oct
(385)
Nov
(363)
Dec
(437)
2009 Jan
(500)
Feb
(301)
Mar
(409)
Apr
(486)
May
(545)
Jun
(391)
Jul
(518)
Aug
(497)
Sep
(492)
Oct
(429)
Nov
(357)
Dec
(310)
2010 Jan
(371)
Feb
(657)
Mar
(519)
Apr
(432)
May
(312)
Jun
(416)
Jul
(477)
Aug
(386)
Sep
(419)
Oct
(435)
Nov
(320)
Dec
(202)
2011 Jan
(321)
Feb
(413)
Mar
(299)
Apr
(215)
May
(284)
Jun
(203)
Jul
(207)
Aug
(314)
Sep
(321)
Oct
(259)
Nov
(347)
Dec
(209)
2012 Jan
(322)
Feb
(414)
Mar
(377)
Apr
(179)
May
(173)
Jun
(234)
Jul
(295)
Aug
(239)
Sep
(276)
Oct
(355)
Nov
(144)
Dec
(108)
2013 Jan
(170)
Feb
(89)
Mar
(204)
Apr
(133)
May
(142)
Jun
(89)
Jul
(160)
Aug
(180)
Sep
(69)
Oct
(136)
Nov
(83)
Dec
(32)
2014 Jan
(71)
Feb
(90)
Mar
(161)
Apr
(117)
May
(78)
Jun
(94)
Jul
(60)
Aug
(83)
Sep
(102)
Oct
(132)
Nov
(154)
Dec
(96)
2015 Jan
(45)
Feb
(138)
Mar
(176)
Apr
(132)
May
(119)
Jun
(124)
Jul
(77)
Aug
(31)
Sep
(34)
Oct
(22)
Nov
(23)
Dec
(9)
2016 Jan
(26)
Feb
(17)
Mar
(10)
Apr
(8)
May
(4)
Jun
(8)
Jul
(6)
Aug
(5)
Sep
(9)
Oct
(4)
Nov
Dec
2017 Jan
(5)
Feb
(7)
Mar
(1)
Apr
(5)
May
Jun
(3)
Jul
(6)
Aug
(1)
Sep
Oct
(2)
Nov
(1)
Dec
2018 Jan
Feb
Mar
Apr
(1)
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2020 Jan
Feb
Mar
Apr
May
(1)
Jun
Jul
Aug
Sep
Oct
Nov
Dec
2025 Jan
(1)
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
S M T W T F S

1
(6)
2
3
(11)
4
(1)
5
(26)
6
(3)
7
(9)
8
(9)
9
10
(4)
11
(4)
12
(4)
13
(5)
14
15
(1)
16
(2)
17
(6)
18
19
(1)
20
(3)
21
(2)
22
23
(6)
24
(3)
25
(7)
26
(2)
27
28
29
(2)
30
(7)




Showing 11 results of 11

From: Alejandro U. <ale...@gm...> - 2015年06月03日 20:19:53
Hi, I am trying to get a live scrolling graph built from data send by two
arduino sensors. Although live data is being shown in the graph I am not
able to get the x axis scrolling. Actually, after reaching the point
established by the counter (in this case cnt>10), the plotting stops. The
arduino and Python codes I am working with are included below. I would very
much appreciate if you can help me getting the scrolling graph working.
ARDUINO CODE
#include "Wire.h" // imports the wire library for talking over I2C
#include "Adafruit_BMP085.h" // import the Pressure Sensor Library
Adafruit_BMP085 mySensor; // create sensor object called mySensor
float tempC; // Variable for holding temp in C
float tempF; // Variable for holding temp in F
float pressure; //Variable for holding pressure reading
void setup(){
Serial.begin(115200); //turn on serial monitor
mySensor.begin(); //initialize mySensor
}
void loop() {
tempC = mySensor.readTemperature(); // Be sure to declare your variables
tempF = tempC*1.8 + 32.; // Convert degrees C to F
pressure=mySensor.readPressure(); //Read Pressure
Serial.print(tempF);
Serial.print(" , ");
Serial.println(pressure);
delay(250); //Pause between readings.
}
​PYTHON CODE
​import serial # import Serial Library
import numpy # Import numpy
import matplotlib.pyplot as plt #import matplotlib library
from drawnow import *
tempF= []
pressure=[]
arduinoData = serial.Serial('com6', 115200) #Creating our serial object
named arduinoData
plt.ion() #Tell matplotlib you want interactive mode to plot live data
cnt=0
def makeFig(): #Create a function that makes our desired plot
 plt.ylim(0,90) #Set y min and max values
 plt.title('My Live Streaming Sensor Data') #Plot the title
 plt.grid(True) #Turn the grid on
 plt.ylabel('Temp F') #Set ylabels
 plt.plot(tempF, 'ro-', label='Degrees F') #plot the temperature
 plt.legend(loc='upper left') #plot the legend
 plt2=plt.twinx() #Create a second y axis
 plt.ylim(0,90) #Set limits of second y axis-
adjust to readings you are getting
 plt2.plot(pressure, 'b^-', label='Pressure (Pa)') #plot pressure data
 plt2.set_ylabel('Pressrue (Pa)') #label second y axis
 plt2.ticklabel_format(useOffset=False) #Force matplotlib to
NOT autoscale y axis
 plt2.legend(loc='upper right') #plot the legend
while True: # While loop that loops forever
 while (arduinoData.inWaiting()==0): #Wait here until there is data
 pass #do nothing
 arduinoString = arduinoData.readline() #read the line of text from the
serial port
 dataArray = arduinoString.split(',') #Split it into an array called
dataArray
 temp = float( dataArray[0]) #Convert first element to
floating number and put in temp
 P = float( dataArray[1]) #Convert second element to
floating number and put in P
 tempF.append(temp) #Build our tempF array by
appending temp readings
 pressure.append(P) #Building our pressure array by
appending P readings
 drawnow(makeFig) #Call drawnow to update our live
graph
 plt.pause(.000001) #Pause Briefly. Important to
keep drawnow from crashing
 cnt=cnt+1
 if(cnt>10): #If you have 50 or more points,
delete the first one from the array
 tempF.pop(0) #This allows us to just see the
last 50 data points
 pressure.pop(0)
From: Yuxiang W. <yw...@vi...> - 2015年06月03日 20:00:31
Hi Juan,
FYI - you forgot to reply to the mailing list in your previous email...
As for the problem, as Eric mentioned, it seems to be a problem with your
plot_posterior_nodes function. That one is out of the matplotlib library,
and I guess it belongs to the HDDM package. You might want to ask people in
their mailing list for more help,
Shawn
On Wed, Jun 3, 2015 at 2:10 PM, Juan Wu <wuj...@gm...> wrote:
> Shawn,
>
> Thanks so much for your prompt reply. This is my code, but it calls other
> package (i.e., HDDM).
>
> v_Neutral, v_Win, v_Loss = m_within_subj.nodes_db.ix[["v_Intercept",
> "v_C(Value_Cond,
> Treatment('Neutral'))[T.Win]",
> "v_C(Value_Cond,
> Treatment('Neutral'))[T.Loss]"], 'node']
> hddm.analyze.plot_posterior_nodes([v_Neutral, v_Win, v_Loss])
> plt.xlabel('drift-rate')
> plt.ylabel('Posterior probability')
> plt.title('Group mean posteriors of within-subject drift-rate effects.')
> plt.savefig('E4_within_subject_design.pdf')
>
> I also tried this, but it also did not work.
>
> v_Neutral, v_Win, v_Loss = m_within_subj.nodes_db.ix[["v_Intercept",
> "v_C(Value_Cond,
> Treatment('Neutral'))[T.Win]",
> "v_C(Value_Cond,
> Treatment('Neutral'))[T.Loss]"], 'node']
> #hddm.analyze.plot_posterior_nodes([v_Neutral, v_Win, v_Loss])
> hddm.analyze.plot_posterior_nodes([float(v_Neutral), float(v_Win),
> float(v_Loss)])
> plt.xlabel('drift-rate')
> plt.ylabel('Posterior probability')
> plt.title('Group mean posteriors of within-subject drift-rate effects.')
> plt.savefig('E4_within_subject_design.pdf')
>
>
>
> On Wed, Jun 3, 2015 at 2:06 PM, Yuxiang Wang <yw...@vi...> wrote:
>
>> Hi Juan,
>>
>> Could you post a minimal code to reproduce your issue?
>>
>> Shawn
>>
>> On Wed, Jun 3, 2015 at 2:03 PM, Juan Wu <wuj...@gm...> wrote:
>>
>>> Hi, List experts,
>>>
>>> Any one can help for this error solution? I googled but did not find
>>> this report.
>>>
>>> Thanks in adance...
>>>
>>> <matplotlib.figure.Figure at 0x1afe8f50>
>>> Traceback (most recent call last):
>>>
>>> File "<ipython-input-38-7909dff7bc28>", line 5, in <module>
>>> hddm.analyze.plot_posterior_nodes([float(v_Neutral), float(v_Win),
>>> float(v_Loss)])
>>>
>>> File "C:\Anaconda\lib\site-packages\kabuki\analyze.py", line 34, in
>>> plot_posterior_nodes
>>> lb = min([min(node.trace()[:]) for node in nodes])
>>>
>>> AttributeError: 'float' object has no attribute 'trace'
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>
>>
>> --
>> Yuxiang "Shawn" Wang
>> Gerling Research Lab
>> University of Virginia
>> yw...@vi...
>> +1 (434) 284-0836
>> https://sites.google.com/a/virginia.edu/yw5aj/
>>
>
>
-- 
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw...@vi...
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/
From: Eric F. <ef...@ha...> - 2015年06月03日 18:12:45
On 2015年06月03日 8:03 AM, Juan Wu wrote:
> Hi, List experts,
>
> Any one can help for this error solution? I googled but did not find
> this report.
>
> Thanks in adance...
>
> <matplotlib.figure.Figure at 0x1afe8f50>
> Traceback (most recent call last):
>
> File "<ipython-input-38-7909dff7bc28>", line 5, in <module>
> hddm.analyze.plot_posterior_nodes([float(v_Neutral), float(v_Win),
> float(v_Loss)])
>
> File "C:\Anaconda\lib\site-packages\kabuki\analyze.py", line 34, in
> plot_posterior_nodes
> lb = min([min(node.trace()[:]) for node in nodes])
>
> AttributeError: 'float' object has no attribute 'trace'
This error is not coming from matplotlib at all. plot_posterior_nodes 
is not our function.
Eric
From: Yuxiang W. <yw...@vi...> - 2015年06月03日 18:06:45
Hi Juan,
Could you post a minimal code to reproduce your issue?
Shawn
On Wed, Jun 3, 2015 at 2:03 PM, Juan Wu <wuj...@gm...> wrote:
> Hi, List experts,
>
> Any one can help for this error solution? I googled but did not find this
> report.
>
> Thanks in adance...
>
> <matplotlib.figure.Figure at 0x1afe8f50>
> Traceback (most recent call last):
>
> File "<ipython-input-38-7909dff7bc28>", line 5, in <module>
> hddm.analyze.plot_posterior_nodes([float(v_Neutral), float(v_Win),
> float(v_Loss)])
>
> File "C:\Anaconda\lib\site-packages\kabuki\analyze.py", line 34, in
> plot_posterior_nodes
> lb = min([min(node.trace()[:]) for node in nodes])
>
> AttributeError: 'float' object has no attribute 'trace'
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
-- 
Yuxiang "Shawn" Wang
Gerling Research Lab
University of Virginia
yw...@vi...
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/
From: Juan Wu <wuj...@gm...> - 2015年06月03日 18:03:57
Hi, List experts,
Any one can help for this error solution? I googled but did not find this
report.
Thanks in adance...
<matplotlib.figure.Figure at 0x1afe8f50>
Traceback (most recent call last):
 File "<ipython-input-38-7909dff7bc28>", line 5, in <module>
 hddm.analyze.plot_posterior_nodes([float(v_Neutral), float(v_Win),
float(v_Loss)])
 File "C:\Anaconda\lib\site-packages\kabuki\analyze.py", line 34, in
plot_posterior_nodes
 lb = min([min(node.trace()[:]) for node in nodes])
AttributeError: 'float' object has no attribute 'trace'
From: Benjamin R. <ben...@ou...> - 2015年06月03日 16:43:23
The plot will autoscale base on the data that has been plotted to it. In
your code, you are repeatedly calling plot(), albeit with a "scrolled"
version of the data, but all of the previous calls to plot() are still
visible. Also, no x-coordinate information is provided to the calls to
plot(), so each new call to plot() only overlays on top of the previous
calls.
I also see that you are using the interactive mode. This isn't really
necessary. I would suggest reading through some of the animation examples
to see how to automatically update your plot:
http://matplotlib.org/examples/animation/index.html . I would particularly
point out the "animate_decay" example. While it isn't a scrolling example,
you can see how to update an existing plot with new data from a generator.
It would then just be a matter of updating the x-limits for each update.
I hope that helps!
Ben Root
On Wed, Jun 3, 2015 at 12:17 PM, Alejandro Ureta <
ale...@gm...> wrote:
> Hi, I am trying to get a live scrolling graph built from data send by two
> arduino sensors. Although live data is being shown in the graph I am not
> able to get it scrolling. The arduino and Python codes I am working with
> are included below. I would very much appreciate if you can help me getting
> the scrolling graph working.
>
>
>
> PYTHON CODE:
>
> import serial # import Serial Library
>
> import numpy # Import numpy
>
> import matplotlib.pyplot as plt #import matplotlib library
>
> from drawnow import *
>
>
>
> tempF= []
>
> pressure= []
>
>
>
> arduinoData = serial.Serial('com6', 115200) #Creating our serial object
> named arduinoData
>
> plt.ion() #Tell matplotlib you want interactive mode to plot live data
>
> cnt=0
>
>
>
> def makeFig(): #Create a function that makes our desired plot
>
> plt.ylim(0,500) #Set y min and max
> values
>
> plt.title('Frequency vs Time') #Plot the title
>
> plt.grid(True) #Turn the grid on
>
> plt.ylabel('Frequency (pulses/sec)') #Set
> ylabels
>
> plt.plot(tempF, 'ro-', label='pulses/sec') #plot the temperature
>
> plt.legend(loc='upper left') #plot the legend
>
>
>
>
>
> plt2=plt.twinx() #Create a second y axis
>
> plt.ylim(0,500) #Set limits of second y
> axis- adjust to readings you are getting
>
> plt2.plot(pressure, 'b^-', label='Pressure (Pa)') #plot pressure data
>
> plt2.set_ylabel('Pressrue (Pa)') #label second y
> axis
>
> plt2.ticklabel_format(useOffset=False) #Force matplotlib to
> NOT autoscale y axis
>
> plt2.legend(loc='upper right') #plot the legend
>
>
>
>
>
> while True: # While loop that loops forever
>
> while (arduinoData.inWaiting()==0): #Wait here until there is data
>
> pass #do nothing
>
> arduinoString = arduinoData.readline() #read the line of text from the
> serial port
>
> dataArray = arduinoString.split(',') #Split it into an array called
> dataArray
>
> temp = float(dataArray[0]) #Convert first element to
> floating number and put in temp
>
> pres = float(dataArray[1]) #Convert second element to
> floating number and put in P
>
> tempF.append(temp) #Build our tempF array by
> appending temp readings
>
> pressure.append(pres) #Building our pressure
> array by appending P readings
>
> drawnow(makeFig) #Call drawnow to update our
> live graph
>
> plt.pause(.000001) #Pause Briefly. Important to
> keep drawnow from crashing
>
> cnt=cnt+1
>
> if(cnt>10): #If you have 50 or more points,
> delete the first one from the array
>
> tempF.pop(0) #This allows us to just see the
> last 50 data points
>
> pressure.pop(0)
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ARDUINO CODE:
>
>
>
>
>
> #include "Wire.h" // imports the wire library for talking over I2C
>
> #include "Adafruit_BMP085.h" // import the Pressure Sensor Library
>
> Adafruit_BMP085 mySensor; // create sensor object called mySensor
>
>
>
> float tempC; // Variable for holding temp in C
>
> float tempF; // Variable for holding temp in F
>
> float pressure; //Variable for holding pressure reading
>
>
>
> void setup(){
>
> Serial.begin(115200); //turn on serial monitor
>
> mySensor.begin(); //initialize mySensor
>
> }
>
>
>
> void loop() {
>
> tempC = mySensor.readTemperature(); // Be sure to declare your variables
>
> tempF = tempC*1.8 + 32.; // Convert degrees C to F
>
> pressure=mySensor.readPressure(); //Read Pressure
>
>
>
>
>
> Serial.print(tempF);
>
> Serial.print(" , ");
>
> Serial.println(pressure);
>
> delay(250); //Pause between readings.
>
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
From: Alejandro U. <ale...@gm...> - 2015年06月03日 16:17:59
Hi, I am trying to get a live scrolling graph built from data send by two
arduino sensors. Although live data is being shown in the graph I am not
able to get it scrolling. The arduino and Python codes I am working with
are included below. I would very much appreciate if you can help me getting
the scrolling graph working.
PYTHON CODE:
import serial # import Serial Library
import numpy # Import numpy
import matplotlib.pyplot as plt #import matplotlib library
from drawnow import *
tempF= []
pressure= []
arduinoData = serial.Serial('com6', 115200) #Creating our serial object
named arduinoData
plt.ion() #Tell matplotlib you want interactive mode to plot live data
cnt=0
def makeFig(): #Create a function that makes our desired plot
 plt.ylim(0,500) #Set y min and max
values
 plt.title('Frequency vs Time') #Plot the title
 plt.grid(True) #Turn the grid on
 plt.ylabel('Frequency (pulses/sec)') #Set
ylabels
 plt.plot(tempF, 'ro-', label='pulses/sec') #plot the temperature
 plt.legend(loc='upper left') #plot the legend
 plt2=plt.twinx() #Create a second y axis
 plt.ylim(0,500) #Set limits of second y axis-
adjust to readings you are getting
 plt2.plot(pressure, 'b^-', label='Pressure (Pa)') #plot pressure data
 plt2.set_ylabel('Pressrue (Pa)') #label second y axis
 plt2.ticklabel_format(useOffset=False) #Force matplotlib to
NOT autoscale y axis
 plt2.legend(loc='upper right') #plot the legend
while True: # While loop that loops forever
 while (arduinoData.inWaiting()==0): #Wait here until there is data
 pass #do nothing
 arduinoString = arduinoData.readline() #read the line of text from the
serial port
 dataArray = arduinoString.split(',') #Split it into an array called
dataArray
 temp = float(dataArray[0]) #Convert first element to floating
number and put in temp
 pres = float(dataArray[1]) #Convert second element to
floating number and put in P
 tempF.append(temp) #Build our tempF array by
appending temp readings
 pressure.append(pres) #Building our pressure
array by appending P readings
 drawnow(makeFig) #Call drawnow to update our live
graph
 plt.pause(.000001) #Pause Briefly. Important to
keep drawnow from crashing
 cnt=cnt+1
 if(cnt>10): #If you have 50 or more points,
delete the first one from the array
 tempF.pop(0) #This allows us to just see the
last 50 data points
 pressure.pop(0)
 ARDUINO CODE:
#include "Wire.h" // imports the wire library for talking over I2C
#include "Adafruit_BMP085.h" // import the Pressure Sensor Library
Adafruit_BMP085 mySensor; // create sensor object called mySensor
float tempC; // Variable for holding temp in C
float tempF; // Variable for holding temp in F
float pressure; //Variable for holding pressure reading
void setup(){
Serial.begin(115200); //turn on serial monitor
mySensor.begin(); //initialize mySensor
}
void loop() {
tempC = mySensor.readTemperature(); // Be sure to declare your variables
tempF = tempC*1.8 + 32.; // Convert degrees C to F
pressure=mySensor.readPressure(); //Read Pressure
Serial.print(tempF);
Serial.print(" , ");
Serial.println(pressure);
delay(250); //Pause between readings.
}
From: Youngung J. <you...@gm...> - 2015年06月03日 14:54:08
I think the problem is associated with the way np.arange is used.
"np.arange(0,10,20)" would return array[0]
If you still would like to manually configure the tick positions the way
you seemed to want, you can use "np.linspace".
Below worked for me.
----
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
x = np.linspace(0,10,50)
y = np.sin(x)
ax.plot(x,y)
ax.grid('on')
leg = plt.legend(['legend 1'])
plt.title('Sample title')
ax.set_ylabel('Sample ylabel')
ax.set_xlabel('Sample xlabel')
ax.set_xticks(np.linspace(0, 10, 11))
ax.set_yticks(np.linspace(-1,1,11))
ax.minorticks_on()
plt.show()
* Youngung Jeong*
On Wed, Jun 3, 2015 at 9:27 AM, <st...@th...> wrote:
> Hm, I tried both suggestions, and still no grid (removed PDF for
> simplicity):
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> fig = plt.figure()
> ax = fig.add_subplot(1,1,1)
>
> x = np.linspace(0,10,50)
> y = np.sin(x)
>
> plt.clf()
>
> plt.clf()
> plt.plot(x,y)
> leg = plt.legend(['legend 1'])
> plt.title('Sample title')
> ax.set_ylabel('Sample ylabel')
> ax.set_xlabel('Sample xlabel')
>
> ax.set_xticks(np.arange(0, 10, 20))
> ax.set_xticks(np.arange(0, 10, 5), minor=True)
> ax.set_yticks(np.arange(-1,1,20))
> ax.set_yticks(np.arange(-1,1,20), minor=True)
>
> ax.minorticks_on()
> ax.grid('on')
> plt.show()
>
>
>
> > And if you meant 'grid', I guess
> >
> > ax.grid('on')
> >
> > should be added.
> >
> > * Youngung Jeong, ì •ì ̃ ì›...*
> >
> > On Mon, Jun 1, 2015 at 4:38 PM, Sterling Smith <sm...@fu...>
> > wrote:
> >
> >> Stephen,
> >>
> >> In your script, you give
> >> ax.minorticks_on
> >> but you need to call that function for anything to occur
> >> ax.minorticks_on()
> >>
> >>
> >> Also, did you see
> >> http://matplotlib.org/examples/pylab_examples/axes_props.html
> >> in case your original question was not answered.
> >>
> >> -Sterling
> >>
> >> On Jun 1, 2015, at 1:24PM, st...@th... wrote:
> >>
> >> > I only see that you added "plt.show()", but neither the grid or the
> >> axis
> >> > labels are showing up.
> >> >
> >> >> Here is what I see with a couple of things modified ?
> >> >> did you expect something else ?
> >> >>
> >> >> from matplotlib.backends.backend_pdf import PdfPages
> >> >> import matplotlib.pyplot as plt
> >> >> import numpy as np
> >> >>
> >> >> fig = plt.figure()
> >> >> ax = fig.add_subplot(1,1,1)
> >> >>
> >> >> x = np.linspace(0,10,50)
> >> >> y = np.sin(x)
> >> >>
> >> >> with PdfPages('grid_test.pdf') as pdf:
> >> >> plt.clf()
> >> >>
> >> >> plt.clf()
> >> >> plt.plot(x,y)
> >> >> leg = plt.legend(['legend 1'])
> >> >> plt.title('Sample title')
> >> >> ax.set_ylabel('Sample ylabel')
> >> >> ax.set_xlabel('Sample xlabel')
> >> >>
> >> >> ax.set_xticks(np.arange(0, 10, 20))
> >> >> ax.set_xticks(np.arange(0, 10, 5), minor=True)
> >> >> ax.set_yticks(np.arange(-1,1,20))
> >> >> ax.set_yticks(np.arange(-1,1,20), minor=True)
> >> >>
> >> >> ax.minorticks_on
> >> >> plt.show()
> >> >>
> >> >> pdf.savefig()
> >> >>
> >> >>
> >> >> [cid:8C8...@or...]
> >> >>
> >> >>
> >> >>
> >> >> On Jun 1, 2015, at 2:49 PM,
> >> >> <st...@th...<mailto:st...@th...>>
> >> >> wrote:
> >> >>
> >> >> I am having an issue with the grid not appearing that I cannot figure
> >> out.
> >> >> Can anyone help? Thanks. --StephenB
> >> >>
> >> >> from matplotlib.backends.backend_pdf import PdfPages
> >> >> import matplotlib.pyplot as plt
> >> >> import numpy as np
> >> >>
> >> >> fig = plt.figure()
> >> >> ax = fig.add_subplot(1,1,1)
> >> >>
> >> >> x = np.linspace(0,10,50)
> >> >> y = np.sin(x)
> >> >>
> >> >> with PdfPages('grid_test.pdf') as pdf:
> >> >> plt.clf()
> >> >>
> >> >> plt.clf()
> >> >> plt.plot(x,y)
> >> >> leg = plt.legend(['legend 1'])
> >> >> plt.title('Sample title')
> >> >> ax.set_ylabel('Sample ylabel')
> >> >> ax.set_xlabel('Sample xlabel')
> >> >>
> >> >> ax.set_xticks(np.arange(0, 10, 20))
> >> >> ax.set_xticks(np.arange(0, 10, 5), minor=True)
> >> >> ax.set_yticks(np.arange(-1,1,20))
> >> >> ax.set_yticks(np.arange(-1,1,20), minor=True)
> >> >>
> >> >> ax.minorticks_on
> >> >>
> >> >> pdf.savefig()
> >> >>
> >> >>
> >> >>
> >>
> ------------------------------------------------------------------------------
> >> >> _______________________________________________
> >> >> Matplotlib-users mailing list
> >> >> Mat...@li...<mailto:
> >> Mat...@li...>
> >> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >> >>
> >> >>
> >> >>
> >> >
> >> >
> >> >
> >> >
> >>
> ------------------------------------------------------------------------------
> >> > _______________________________________________
> >> > Matplotlib-users mailing list
> >> > Mat...@li...
> >> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>
> >>
> >>
> >>
> ------------------------------------------------------------------------------
> >> _______________________________________________
> >> Matplotlib-users mailing list
> >> Mat...@li...
> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >>
> >
>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: Bilheux, Jean-C. <bil...@or...> - 2015年06月03日 13:54:53
Works for me too using
plt.grid()
but I can't find the way to customize the grid (size, type...)?
trying http://matplotlib.org/examples/pylab_examples/axes_props.html 
doesn't do anything for me !
On Jun 3, 2015, at 9:39 AM, <st...@th...>
 wrote:
> But this works:
> 
> import matplotlib.pyplot as plt
> import numpy as np
> 
> fig = plt.figure()
> ax = fig.add_subplot(1,1,1)
> 
> x = np.linspace(0,10,50)
> y = np.sin(x)
> 
> plt.clf()
> 
> plt.clf()
> plt.plot(x,y)
> leg = plt.legend(['legend 1'])
> plt.title('Sample title')
> plt.ylabel('Sample ylabel')
> plt.xlabel('Sample xlabel')
> 
> ax.set_xticks(np.arange(0, 10, 20))
> ax.set_xticks(np.arange(0, 10, 5), minor=True)
> ax.set_yticks(np.arange(-1,1,20))
> ax.set_yticks(np.arange(-1,1,20), minor=True)
> 
> ax.minorticks_on()
> plt.grid(True)
> plt.show()
> 
> 
>> Hm, I tried both suggestions, and still no grid (removed PDF for
>> simplicity):
>> 
>> import matplotlib.pyplot as plt
>> import numpy as np
>> 
>> fig = plt.figure()
>> ax = fig.add_subplot(1,1,1)
>> 
>> x = np.linspace(0,10,50)
>> y = np.sin(x)
>> 
>> plt.clf()
>> 
>> plt.clf()
>> plt.plot(x,y)
>> leg = plt.legend(['legend 1'])
>> plt.title('Sample title')
>> ax.set_ylabel('Sample ylabel')
>> ax.set_xlabel('Sample xlabel')
>> 
>> ax.set_xticks(np.arange(0, 10, 20))
>> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>> ax.set_yticks(np.arange(-1,1,20))
>> ax.set_yticks(np.arange(-1,1,20), minor=True)
>> 
>> ax.minorticks_on()
>> ax.grid('on')
>> plt.show()
>> 
>> 
>> 
>>> And if you meant 'grid', I guess
>>> 
>>> ax.grid('on')
>>> 
>>> should be added.
>>> 
>>> * Youngung Jeong, ì .ì~ì>.*
>>> 
>>> On Mon, Jun 1, 2015 at 4:38 PM, Sterling Smith <sm...@fu...>
>>> wrote:
>>> 
>>>> Stephen,
>>>> 
>>>> In your script, you give
>>>> ax.minorticks_on
>>>> but you need to call that function for anything to occur
>>>> ax.minorticks_on()
>>>> 
>>>> 
>>>> Also, did you see
>>>> http://matplotlib.org/examples/pylab_examples/axes_props.html
>>>> in case your original question was not answered.
>>>> 
>>>> -Sterling
>>>> 
>>>> On Jun 1, 2015, at 1:24PM, st...@th... wrote:
>>>> 
>>>>> I only see that you added "plt.show()", but neither the grid or the
>>>> axis
>>>>> labels are showing up.
>>>>> 
>>>>>> Here is what I see with a couple of things modified ?
>>>>>> did you expect something else ?
>>>>>> 
>>>>>> from matplotlib.backends.backend_pdf import PdfPages
>>>>>> import matplotlib.pyplot as plt
>>>>>> import numpy as np
>>>>>> 
>>>>>> fig = plt.figure()
>>>>>> ax = fig.add_subplot(1,1,1)
>>>>>> 
>>>>>> x = np.linspace(0,10,50)
>>>>>> y = np.sin(x)
>>>>>> 
>>>>>> with PdfPages('grid_test.pdf') as pdf:
>>>>>> plt.clf()
>>>>>> 
>>>>>> plt.clf()
>>>>>> plt.plot(x,y)
>>>>>> leg = plt.legend(['legend 1'])
>>>>>> plt.title('Sample title')
>>>>>> ax.set_ylabel('Sample ylabel')
>>>>>> ax.set_xlabel('Sample xlabel')
>>>>>> 
>>>>>> ax.set_xticks(np.arange(0, 10, 20))
>>>>>> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>>>>>> ax.set_yticks(np.arange(-1,1,20))
>>>>>> ax.set_yticks(np.arange(-1,1,20), minor=True)
>>>>>> 
>>>>>> ax.minorticks_on
>>>>>> plt.show()
>>>>>> 
>>>>>> pdf.savefig()
>>>>>> 
>>>>>> 
>>>>>> [cid:8C8...@or...]
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> On Jun 1, 2015, at 2:49 PM,
>>>>>> <st...@th...<mailto:st...@th...>>
>>>>>> wrote:
>>>>>> 
>>>>>> I am having an issue with the grid not appearing that I cannot
>>>> figure
>>>> out.
>>>>>> Can anyone help? Thanks. --StephenB
>>>>>> 
>>>>>> from matplotlib.backends.backend_pdf import PdfPages
>>>>>> import matplotlib.pyplot as plt
>>>>>> import numpy as np
>>>>>> 
>>>>>> fig = plt.figure()
>>>>>> ax = fig.add_subplot(1,1,1)
>>>>>> 
>>>>>> x = np.linspace(0,10,50)
>>>>>> y = np.sin(x)
>>>>>> 
>>>>>> with PdfPages('grid_test.pdf') as pdf:
>>>>>> plt.clf()
>>>>>> 
>>>>>> plt.clf()
>>>>>> plt.plot(x,y)
>>>>>> leg = plt.legend(['legend 1'])
>>>>>> plt.title('Sample title')
>>>>>> ax.set_ylabel('Sample ylabel')
>>>>>> ax.set_xlabel('Sample xlabel')
>>>>>> 
>>>>>> ax.set_xticks(np.arange(0, 10, 20))
>>>>>> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>>>>>> ax.set_yticks(np.arange(-1,1,20))
>>>>>> ax.set_yticks(np.arange(-1,1,20), minor=True)
>>>>>> 
>>>>>> ax.minorticks_on
>>>>>> 
>>>>>> pdf.savefig()
>>>>>> 
>>>>>> 
>>>>>> 
>>>> ------------------------------------------------------------------------------
>>>>>> _______________________________________________
>>>>>> Matplotlib-users mailing list
>>>>>> Mat...@li...<mailto:
>>>> Mat...@li...>
>>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>>>> 
>>>>>> 
>>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>>> 
>>>> ------------------------------------------------------------------------------
>>>>> _______________________________________________
>>>>> Matplotlib-users mailing list
>>>>> Mat...@li...
>>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>> 
>>>> 
>>>> 
>>>> ------------------------------------------------------------------------------
>>>> _______________________________________________
>>>> Matplotlib-users mailing list
>>>> Mat...@li...
>>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>> 
>>> 
>> 
>> 
>> 
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> 
> 
> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> 
From: <st...@th...> - 2015年06月03日 13:39:33
But this works:
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
x = np.linspace(0,10,50)
y = np.sin(x)
plt.clf()
plt.clf()
plt.plot(x,y)
leg = plt.legend(['legend 1'])
plt.title('Sample title')
plt.ylabel('Sample ylabel')
plt.xlabel('Sample xlabel')
ax.set_xticks(np.arange(0, 10, 20))
ax.set_xticks(np.arange(0, 10, 5), minor=True)
ax.set_yticks(np.arange(-1,1,20))
ax.set_yticks(np.arange(-1,1,20), minor=True)
ax.minorticks_on()
plt.grid(True)
plt.show()
> Hm, I tried both suggestions, and still no grid (removed PDF for
> simplicity):
>
> import matplotlib.pyplot as plt
> import numpy as np
>
> fig = plt.figure()
> ax = fig.add_subplot(1,1,1)
>
> x = np.linspace(0,10,50)
> y = np.sin(x)
>
> plt.clf()
>
> plt.clf()
> plt.plot(x,y)
> leg = plt.legend(['legend 1'])
> plt.title('Sample title')
> ax.set_ylabel('Sample ylabel')
> ax.set_xlabel('Sample xlabel')
>
> ax.set_xticks(np.arange(0, 10, 20))
> ax.set_xticks(np.arange(0, 10, 5), minor=True)
> ax.set_yticks(np.arange(-1,1,20))
> ax.set_yticks(np.arange(-1,1,20), minor=True)
>
> ax.minorticks_on()
> ax.grid('on')
> plt.show()
>
>
>
>> And if you meant 'grid', I guess
>>
>> ax.grid('on')
>>
>> should be added.
>>
>> * Youngung Jeong, ì •ì˜ì›…*
>>
>> On Mon, Jun 1, 2015 at 4:38 PM, Sterling Smith <sm...@fu...>
>> wrote:
>>
>>> Stephen,
>>>
>>> In your script, you give
>>> ax.minorticks_on
>>> but you need to call that function for anything to occur
>>> ax.minorticks_on()
>>>
>>>
>>> Also, did you see
>>> http://matplotlib.org/examples/pylab_examples/axes_props.html
>>> in case your original question was not answered.
>>>
>>> -Sterling
>>>
>>> On Jun 1, 2015, at 1:24PM, st...@th... wrote:
>>>
>>> > I only see that you added "plt.show()", but neither the grid or the
>>> axis
>>> > labels are showing up.
>>> >
>>> >> Here is what I see with a couple of things modified ?
>>> >> did you expect something else ?
>>> >>
>>> >> from matplotlib.backends.backend_pdf import PdfPages
>>> >> import matplotlib.pyplot as plt
>>> >> import numpy as np
>>> >>
>>> >> fig = plt.figure()
>>> >> ax = fig.add_subplot(1,1,1)
>>> >>
>>> >> x = np.linspace(0,10,50)
>>> >> y = np.sin(x)
>>> >>
>>> >> with PdfPages('grid_test.pdf') as pdf:
>>> >> plt.clf()
>>> >>
>>> >> plt.clf()
>>> >> plt.plot(x,y)
>>> >> leg = plt.legend(['legend 1'])
>>> >> plt.title('Sample title')
>>> >> ax.set_ylabel('Sample ylabel')
>>> >> ax.set_xlabel('Sample xlabel')
>>> >>
>>> >> ax.set_xticks(np.arange(0, 10, 20))
>>> >> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>>> >> ax.set_yticks(np.arange(-1,1,20))
>>> >> ax.set_yticks(np.arange(-1,1,20), minor=True)
>>> >>
>>> >> ax.minorticks_on
>>> >> plt.show()
>>> >>
>>> >> pdf.savefig()
>>> >>
>>> >>
>>> >> [cid:8C8...@or...]
>>> >>
>>> >>
>>> >>
>>> >> On Jun 1, 2015, at 2:49 PM,
>>> >> <st...@th...<mailto:st...@th...>>
>>> >> wrote:
>>> >>
>>> >> I am having an issue with the grid not appearing that I cannot
>>> figure
>>> out.
>>> >> Can anyone help? Thanks. --StephenB
>>> >>
>>> >> from matplotlib.backends.backend_pdf import PdfPages
>>> >> import matplotlib.pyplot as plt
>>> >> import numpy as np
>>> >>
>>> >> fig = plt.figure()
>>> >> ax = fig.add_subplot(1,1,1)
>>> >>
>>> >> x = np.linspace(0,10,50)
>>> >> y = np.sin(x)
>>> >>
>>> >> with PdfPages('grid_test.pdf') as pdf:
>>> >> plt.clf()
>>> >>
>>> >> plt.clf()
>>> >> plt.plot(x,y)
>>> >> leg = plt.legend(['legend 1'])
>>> >> plt.title('Sample title')
>>> >> ax.set_ylabel('Sample ylabel')
>>> >> ax.set_xlabel('Sample xlabel')
>>> >>
>>> >> ax.set_xticks(np.arange(0, 10, 20))
>>> >> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>>> >> ax.set_yticks(np.arange(-1,1,20))
>>> >> ax.set_yticks(np.arange(-1,1,20), minor=True)
>>> >>
>>> >> ax.minorticks_on
>>> >>
>>> >> pdf.savefig()
>>> >>
>>> >>
>>> >>
>>> ------------------------------------------------------------------------------
>>> >> _______________________________________________
>>> >> Matplotlib-users mailing list
>>> >> Mat...@li...<mailto:
>>> Mat...@li...>
>>> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>> >>
>>> >>
>>> >>
>>> >
>>> >
>>> >
>>> >
>>> ------------------------------------------------------------------------------
>>> > _______________________________________________
>>> > Matplotlib-users mailing list
>>> > Mat...@li...
>>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> _______________________________________________
>>> Matplotlib-users mailing list
>>> Mat...@li...
>>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>>
>>
>
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Matplotlib-users mailing list
> Mat...@li...
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
From: <st...@th...> - 2015年06月03日 13:28:06
Hm, I tried both suggestions, and still no grid (removed PDF for simplicity):
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(1,1,1)
x = np.linspace(0,10,50)
y = np.sin(x)
plt.clf()
plt.clf()
plt.plot(x,y)
leg = plt.legend(['legend 1'])
plt.title('Sample title')
ax.set_ylabel('Sample ylabel')
ax.set_xlabel('Sample xlabel')
ax.set_xticks(np.arange(0, 10, 20))
ax.set_xticks(np.arange(0, 10, 5), minor=True)
ax.set_yticks(np.arange(-1,1,20))
ax.set_yticks(np.arange(-1,1,20), minor=True)
ax.minorticks_on()
ax.grid('on')
plt.show()
> And if you meant 'grid', I guess
>
> ax.grid('on')
>
> should be added.
>
> * Youngung Jeong, ì •ì˜ì›…*
>
> On Mon, Jun 1, 2015 at 4:38 PM, Sterling Smith <sm...@fu...>
> wrote:
>
>> Stephen,
>>
>> In your script, you give
>> ax.minorticks_on
>> but you need to call that function for anything to occur
>> ax.minorticks_on()
>>
>>
>> Also, did you see
>> http://matplotlib.org/examples/pylab_examples/axes_props.html
>> in case your original question was not answered.
>>
>> -Sterling
>>
>> On Jun 1, 2015, at 1:24PM, st...@th... wrote:
>>
>> > I only see that you added "plt.show()", but neither the grid or the
>> axis
>> > labels are showing up.
>> >
>> >> Here is what I see with a couple of things modified ?
>> >> did you expect something else ?
>> >>
>> >> from matplotlib.backends.backend_pdf import PdfPages
>> >> import matplotlib.pyplot as plt
>> >> import numpy as np
>> >>
>> >> fig = plt.figure()
>> >> ax = fig.add_subplot(1,1,1)
>> >>
>> >> x = np.linspace(0,10,50)
>> >> y = np.sin(x)
>> >>
>> >> with PdfPages('grid_test.pdf') as pdf:
>> >> plt.clf()
>> >>
>> >> plt.clf()
>> >> plt.plot(x,y)
>> >> leg = plt.legend(['legend 1'])
>> >> plt.title('Sample title')
>> >> ax.set_ylabel('Sample ylabel')
>> >> ax.set_xlabel('Sample xlabel')
>> >>
>> >> ax.set_xticks(np.arange(0, 10, 20))
>> >> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>> >> ax.set_yticks(np.arange(-1,1,20))
>> >> ax.set_yticks(np.arange(-1,1,20), minor=True)
>> >>
>> >> ax.minorticks_on
>> >> plt.show()
>> >>
>> >> pdf.savefig()
>> >>
>> >>
>> >> [cid:8C8...@or...]
>> >>
>> >>
>> >>
>> >> On Jun 1, 2015, at 2:49 PM,
>> >> <st...@th...<mailto:st...@th...>>
>> >> wrote:
>> >>
>> >> I am having an issue with the grid not appearing that I cannot figure
>> out.
>> >> Can anyone help? Thanks. --StephenB
>> >>
>> >> from matplotlib.backends.backend_pdf import PdfPages
>> >> import matplotlib.pyplot as plt
>> >> import numpy as np
>> >>
>> >> fig = plt.figure()
>> >> ax = fig.add_subplot(1,1,1)
>> >>
>> >> x = np.linspace(0,10,50)
>> >> y = np.sin(x)
>> >>
>> >> with PdfPages('grid_test.pdf') as pdf:
>> >> plt.clf()
>> >>
>> >> plt.clf()
>> >> plt.plot(x,y)
>> >> leg = plt.legend(['legend 1'])
>> >> plt.title('Sample title')
>> >> ax.set_ylabel('Sample ylabel')
>> >> ax.set_xlabel('Sample xlabel')
>> >>
>> >> ax.set_xticks(np.arange(0, 10, 20))
>> >> ax.set_xticks(np.arange(0, 10, 5), minor=True)
>> >> ax.set_yticks(np.arange(-1,1,20))
>> >> ax.set_yticks(np.arange(-1,1,20), minor=True)
>> >>
>> >> ax.minorticks_on
>> >>
>> >> pdf.savefig()
>> >>
>> >>
>> >>
>> ------------------------------------------------------------------------------
>> >> _______________________________________________
>> >> Matplotlib-users mailing list
>> >> Mat...@li...<mailto:
>> Mat...@li...>
>> >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> >
>> ------------------------------------------------------------------------------
>> > _______________________________________________
>> > Matplotlib-users mailing list
>> > Mat...@li...
>> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>>
>> ------------------------------------------------------------------------------
>> _______________________________________________
>> Matplotlib-users mailing list
>> Mat...@li...
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>

Showing 11 results of 11

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.
Thanks for helping keep SourceForge clean.
X





Briefly describe the problem (required):
Upload screenshot of ad (required):
Select a file, or drag & drop file here.
Screenshot instructions:

Click URL instructions:
Right-click on the ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)

More information about our ad policies

Ad destination/click URL:

AltStyle によって変換されたページ (->オリジナル) /