Re: [Matplotlib-users] problem: AttributeError: 'float' object has no attribute 'trace'

2015-06-03 Thread Yuxiang Wang
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 wujua...@gmail.com 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...@virginia.edu 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 wujua...@gmail.com 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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




 --
 Yuxiang Shawn Wang
 Gerling Research Lab
 University of Virginia
 yw...@virginia.edu
 +1 (434) 284-0836
 https://sites.google.com/a/virginia.edu/yw5aj/





-- 
Yuxiang Shawn Wang
Gerling Research Lab
University of Virginia
yw...@virginia.edu
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Problems with Real Time Plotting

2015-06-03 Thread Alejandro Ureta
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 cnt10), 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(.01) #Pause Briefly. Important to
keep drawnow from crashing
cnt=cnt+1
if(cnt10):#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)
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Turning grid on

2015-06-03 Thread Bilheux, Jean-Christophe
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, step...@theboulets.net
 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 smit...@fusion.gat.com
 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, step...@theboulets.net 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:8C80F2A2-AD50-4E09-B0EF-0596312F5093@ornl.gov]
 
 
 
 On Jun 1, 2015, at 2:49 PM,
 step...@theboulets.netmailto:step...@theboulets.net
 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
 Matplotlib-users@lists.sourceforge.netmailto:
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 
 
 
 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 
 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 --
 ___
 Matplotlib-users mailing list
 

Re: [Matplotlib-users] Turning grid on

2015-06-03 Thread Youngung Jeong
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, step...@theboulets.net 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 smit...@fusion.gat.com
  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, step...@theboulets.net 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:8C80F2A2-AD50-4E09-B0EF-0596312F5093@ornl.gov]
  
  
  
   On Jun 1, 2015, at 2:49 PM,
   step...@theboulets.netmailto:step...@theboulets.net
   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
   Matplotlib-users@lists.sourceforge.netmailto:
  Matplotlib-users@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/matplotlib-users
  
  
  
  
  
  
  
 
 --
   ___
   Matplotlib-users mailing list
   Matplotlib-users@lists.sourceforge.net
   https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 --
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 




 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Turning grid on

2015-06-03 Thread stephen
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 smit...@fusion.gat.com
 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, step...@theboulets.net 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:8C80F2A2-AD50-4E09-B0EF-0596312F5093@ornl.gov]
 
 
 
  On Jun 1, 2015, at 2:49 PM,
  step...@theboulets.netmailto:step...@theboulets.net
  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
  Matplotlib-users@lists.sourceforge.netmailto:
 Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 
 
 
 --
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users



 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users





 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Turning grid on

2015-06-03 Thread stephen
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 smit...@fusion.gat.com
 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, step...@theboulets.net 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:8C80F2A2-AD50-4E09-B0EF-0596312F5093@ornl.gov]
 
 
 
  On Jun 1, 2015, at 2:49 PM,
  step...@theboulets.netmailto:step...@theboulets.net
  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
  Matplotlib-users@lists.sourceforge.netmailto:
 Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users
 
 
 
 
 
 
 
 --
  ___
  Matplotlib-users mailing list
  Matplotlib-users@lists.sourceforge.net
  https://lists.sourceforge.net/lists/listinfo/matplotlib-users



 --
 ___
 Matplotlib-users mailing list
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users





--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] Live Scrolling Matplotlib graph

2015-06-03 Thread Alejandro Ureta
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(.01) #Pause Briefly. Important to
keep drawnow from crashing

cnt=cnt+1

if(cnt10):#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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Live Scrolling Matplotlib graph

2015-06-03 Thread Benjamin Root
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 
alejandro.r.ur...@gmail.com 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(.01) #Pause Briefly. Important to
 keep drawnow from crashing

 cnt=cnt+1

 if(cnt10):#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
 Matplotlib-users@lists.sourceforge.net
 

[Matplotlib-users] problem: AttributeError: 'float' object has no attribute 'trace'

2015-06-03 Thread Juan Wu
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
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem: AttributeError: 'float' object has no attribute 'trace'

2015-06-03 Thread Yuxiang Wang
Hi Juan,

Could you post a minimal code to reproduce your issue?

Shawn

On Wed, Jun 3, 2015 at 2:03 PM, Juan Wu wujua...@gmail.com 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
 Matplotlib-users@lists.sourceforge.net
 https://lists.sourceforge.net/lists/listinfo/matplotlib-users




-- 
Yuxiang Shawn Wang
Gerling Research Lab
University of Virginia
yw...@virginia.edu
+1 (434) 284-0836
https://sites.google.com/a/virginia.edu/yw5aj/
--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] problem: AttributeError: 'float' object has no attribute 'trace'

2015-06-03 Thread Eric Firing
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



--
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users