python - plotting with subsets of data -


so have various arrays of data treatments coded dummy variables

x=[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1] z=[1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0] d=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5] y=[1,2,3,4,5,0,0,1,0,1,1,10,20,35,50,1,10,15,20,25] 

and plot 4 plots @ same time in separate figures each of combination of treatments 1 plot.

so

plt.figure(1) plt.subplot(411) plt.plot(d,y[x==0],[z==0])  plt.figure(2)  plt.subplot(412) plt.plot(d,y[x==1],[z==0])  plt.figure(3) plt.subplot(421) plt.plot(d,y[x==0],[z==1])  plt.figure(4) plt.subplot(422) plt.plot(d,y[x==1],[z==1])  p.show() 

but error saying third argument has format string.

i don't want break data smaller chunks before plotting running data through regression model prior plotting , seems though may complicate things little me.

any appreciated inexperienced python. thank

clarification op: i'm trying 4 graphs in 1 pane with;

  1. the first plot being ~ y when x=0 , z=0,
  2. the 2nd plot being ~ y when x=1 , z= 0
  3. the third being ~ y when x=0 , z=1 and
  4. the last being ~ y when x=1 , z=1

to achieve need extract correct data before plotting it.

import matplotlib.pyplot plt  x=[0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1] z=[1,1,1,1,1,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0] y=[1,2,3,4,5,0,0,1,0,1,1,10,20,35,50,1,10,15,20,25] d=[1,2,3,4,5,1,2,3,4,5,1,2,3,4,5,1,2,3,4,5]   plt.figure(1)  zipped = list(zip(x, z, y, d)) filtered = [(ey, ed) ex, ez, ey, ed in zipped if ex==0 , ez==0] unzipped = list(zip(*filtered)) plotx = unzipped[1] ploty = unzipped[0]  plt.subplot(411) plt.title("x=0 z=0") plt.plot(plotx, ploty, 'o-')  zipped = list(zip(x, z, y, d)) filtered = [(ey, ed) ex, ez, ey, ed in zipped if ex==0 , ez==1] unzipped = list(zip(*filtered)) plotx = unzipped[1] ploty = unzipped[0]  plt.subplot(412) plt.title("x=1 z=0") plt.plot(plotx, ploty, 'o-')  zipped = list(zip(x, z, y, d)) filtered = [(ey, ed) ex, ez, ey, ed in zipped if ex==1 , ez==0] unzipped = list(zip(*filtered)) plotx = unzipped[1] ploty = unzipped[0]  plt.subplot(413) plt.title("x=0 z=1") plt.plot(plotx, ploty, 'o-')  zipped = list(zip(x, z, y, d)) filtered = [(ey, ed) ex, ez, ey, ed in zipped if ex==1 , ez==1] unzipped = list(zip(*filtered)) plotx = unzipped[1] ploty = unzipped[0]  plt.subplot(414) plt.title("x=1 z=1") plt.plot(plotx, ploty, 'o-')  plt.show() 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -