Plot.plot() not working
I am using Ubuntu 20.04 and Plot.plot() not working. I tried different examples in yade document. None of them are working. Can anyone help me to fix this? I am new to yade.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello,
> I am new to yade.
welcome :-)
please read [1] and provide more information.
> I am using Ubuntu 20.04
what Yade are you using?
System package? self-compiled?
Which version?
... ?
> Plot.plot() not working
Plot (capital P) should not work.
If referring to code, always write/paste code exactly used. Here assuming it should have been plot.plot()?
> I tried different examples in yade document
please give at least one specific example.
> None of them are working
what does "none are working" mean?
Do you get any error?
What are the symptoms? (errors? plot is shown, but not correctly? plot is shown but is not updating? ... ?)
... ?
Cheers
Jan
Revision history for this message
|
#2 |
>what Yade are you using?
System package? self-compiled?
I installed it using sudo apt-get install yade.
>Which version?
Yade 2020.01a
python version 3.8.10
matplotlib version 3.6.0
> If referring to code, always write/paste code exactly used. Here assuming it should have been plot.plot()?
Sorry for the confusion. I meant plot.plot() only.
>please give at least one specific example.
I tried to run this code But I am getting "Attribute error: PathCollection.
# gravity deposition in box, showing how to plot and save history of data,
# and how to control the simulation while it is running by calling
# python functions from within the simulation loop
# import yade modules that we will use below
from yade import pack, plot
# create rectangular box from facets
O.bodies.
# create empty sphere packing
# sphere packing is not equivalent to particles in simulation, it contains only the pure geometry
sp = pack.SpherePack()
# generate randomly spheres with uniform radius distribution
sp.makeCloud((0, 0, 0), (1, 1, 1), rMean=.05, rRelFuzz=.5)
# add the sphere pack to the simulation
sp.toSimulation()
O.engines = [
# handle sphere+sphere and facet+sphere collisions
),
# call the checkUnbalanced function (defined below) every 2 seconds
# call the addPlotData function every 200 steps
]
O.dt = .5 * PWaveTimeStep()
# enable energy tracking; any simulation parts supporting it
# can create and update arbitrary energy types, which can be
# accessed as O.energy[
O.trackEnergy = True
# if the unbalanced forces goes below .05, the packing
# is considered stabilized, therefore we stop collected
# data history and stop
def checkUnbalanced():
if unbalancedForce() < .05:
O.pause()
plot.
# plot.saveGnuplo
# collect history of data which will be plotted
def addPlotData():
# each item is given a names, by which it can be the unsed in plot.plots
# the **O.energy converts dictionary-like O.energy to plot.addData arguments
plot.addData(
# define how to plot data: 'i' (step number) on the x-axis, unbalanced force
# on the left y-axis, all energies on the right y-axis
# (O.energy.keys is function which will be called to get all defined energies)
# None separates left and right y-axis
plot.plots = {'i': ('unbalanced', None, O.energy.keys)}
# show the plot on the screen, and update while the simulation runs
plot.plot()
O.saveTmp()
Revision history for this message
|
#3 |
> But I am getting "Attribute error
please provide full error message ([1], point 2)
Cheers
Jan
Revision history for this message
|
#4 |
This is the error I am getting.
AttributeError Traceback (most recent call last)
/usr/bin/yade in <module>
--> plot.plot()
/usr/lib/
598 .. note:: For backwards compatibility reasons, *noShow* option will return list of figures for multiple figures but a single figure (rather than list with 1 element) if there is only 1 figure.
599 """
--> 600 createPlots(
601 global currLineRefs
602 figs=set(
/usr/lib/
460 if yNameFuncs:
461 axes.yadeYNames
--> 462 createLines(
463 if axesWd>0:
464 pylab.axhline(
/usr/lib/
442 scatterPt=[0,0] if len(data[
443 # if current value is NaN, use zero instead
--> 444 scatter=
445 currLineRefs.
446 axes=line.axes
~/.local/
2776 vmin=None, vmax=None, alpha=None, linewidths=None, *,
2777 edgecolors=None, plotnonfinite=
-> 2778 __ret = gca().scatter(
2779 x, y, s=s, c=c, marker=marker, cmap=cmap, norm=norm,
2780 vmin=vmin, vmax=vmax, alpha=alpha, linewidths=
~/.local/
1421 def inner(ax, *args, data=None, **kwargs):
1422 if data is None:
-> 1423 return func(ax, *map(sanitize_
1424
1425 bound = new_sig.bind(ax, *args, **kwargs)
~/.local/
4624 "No data for colormapping provided via 'c'. "
4625 f"Parameters {keys_str} will be ignored")
-> 4626 collection.
4627
4628 # Classic mode only:
~/.local/
1184 The lack of prenormalization is to maintain backcompatibility.
1185 """
-> 1186 return self._update_props(
1187 kwargs, "{cls._
1188 "{prop_name!r}")
~/.local/
1158 func = getattr(self, f"set_{k}", None)
1159 if not callable(func):
-> 1160 raise AttributeError(
1161 errfmt.
1162 ret.append(func(v))
AttributeError: PathCollection.
Revision history for this message
|
#5 |
> matplotlib version 3.6.0
> ~/.local/
it seems like you have installed matplotlib with pip, right?
Documentation [2] suggest using "system version" (python3-matplotlib package), which should be version 3.1.2 [3].
You can try several options:
- uninstall pip version and install system version of matplotlib
- install matplotlib with pip, but version 3.1.2.
- use yadedaily [4] which should (could?) work with newer version
Cheers
Jan
[2] https:/
[3] https:/
[4] https:/
Can you help with this problem?
Provide an answer of your own, or ask Namzu for more information if necessary.