# plot 2 figures

Asked by hafsa on 2019-02-12

hi everyone ,
i want to plot 2 figures the first is for kinetic energy and the second for pos_z of one particle .
i obtain just the second figure , why the first douen't plot ?
there's my code :

#ekin=kineticEnergy()/n
# oscillation
if O.iter >=1e4:
O.engines=O.engines+[HarmonicMotionEngine(A=[0,0,1.], f=[0,0,2.6], fi = [0.0,0.0,0.0],ids =Cylinder)]
# save in file

plot.plots={'i':['e']+O.energy.keys()}
plot.plots={'i':['pos_z']}
plot.plot()
plot.live=True

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-02-12
Last query:
2019-02-12
2019-02-12
 Jan Stránský (honzik) said on 2019-02-12: #1

> plot.plots={'i':['e']+O.energy.keys()}
> plot.plots={'i':['pos_z']}

the second assignment just assign {'i':['pos_z']}, overwriting the previous values.

plot.plots = {'i': ..., 'i ': ...} # note the space in 'i ' 
or
plot.plots = {'i':('e',None,'pos_z')} # 

cheers
Jan

 hafsa (sebbah.hafsa) said on 2019-02-12: #2

hi Jan ,
i tried the both and after condition (O.iter>= 1e4) the the curve ( kinetic and pos_z) becomes transparent .

#ekin=kineticEnergy()/n
# oscillation
if O.iter >=0.8*1e4:
O.engines=O.engines+[HarmonicMotionEngine(A=[0,0,1.], f=[0,0,2.6], fi = [0.0,0.0,0.0],ids =Cylinder)]
# save in file
pos_z=O.bodies.state.pos

#plot.plots={'i':['e']+O.energy.keys()}
#plot.plots = {'i ':('e',None,'pos_z')}
plot.plots={'i':['pos_z',],'i ':['e']+O.energy.keys()}
plot.plot()
plot.live=True

 Jan Stránský (honzik) said on 2019-02-12: #3

a MWE  please
Jan

 hafsa (sebbah.hafsa) said on 2019-02-12: #4

i tried plot.plots={'i':['pos_z',],'i ':['e']+O.energy.keys()} and when O.iter = 1e4 the curves of kinetic energy and pos_z become transparent . Jan Stránský (honzik) said on 2019-02-12: #5

For next time, MWE = Minimal Working Example .

in your case, the plot becomes transparent because there are not continuous data to plot (plot .addData adds NaN in case some data are missing):

> plot.addData(i=O.iter,e=log(kineticEnergy()/n), **O.energy) # 1st plot.addData, adding NaN for pos_z
> if O.iter >=0.8*1e4:

solution:

if O.iter > ...: