-
-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 992 plot arrays #1008
Issue 992 plot arrays #1008
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rtimms , some comments
pybamm/__init__.py
Outdated
@@ -223,7 +223,7 @@ def version(formatted=False): | |||
# | |||
# other | |||
# | |||
from .quick_plot import QuickPlot, dynamic_plot, ax_min, ax_max | |||
from .quick_plot import QuickPlot, plot, plot2D, dynamic_plot, ax_min, ax_max |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be worth making a new plotting folder with a few different functions in different files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed
y = pybamm.Array(np.array([6, 16, 78])) | ||
X, Y = pybamm.meshgrid(x, y) | ||
|
||
pybamm.plot2D(X, Y, Y, xlabel="x", ylabel="y", title="title", testing=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could plot2D
automatically do meshgrid(x,y) if they aren't given in meshgrid form?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turns out contourf handles this provided they are the correct shape. have added some lines to account for this
pybamm/expression_tree/array.py
Outdated
|
||
|
||
def linspace(start, stop, num=50, **kwargs): | ||
"Creates a linearly spaced array" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why pick out num
from the kwargs
? Also, link to np.linspace
docs for the kwargs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did this so you can do pybamm.linspace(0,1,100)
without needing to do num=100
as I think it's a pretty common use case and you can just do np.linspace(0,1,100)
directly. that didn't work unless I picked out num
but maybe there is a better/more common solution?
pybamm/expression_tree/array.py
Outdated
|
||
|
||
def meshgrid(x, y, **kwargs): | ||
"Return coordinate matrices as from coordinate vectors" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
link np.meshgrid
docs for the kwargs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All good, thanks
Description
Added basic plots for 1D and 2D arrays (
pybamm.plot
andpybamm.plot2D
). I've left these as separate methods, but I guess they could be combined and the appropriate plot called depending on what arrays you pass. On the other hand, maybe it is better to be explicit.Also added
pybamm.linspace
andpybamm.meshgrid
to quickly create some common arrays.Fixes #992
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ flake8
$ python run-tests.py --unit
$ cd docs
and then$ make clean; make html
You can run all three at once, using
$ python run-tests.py --quick
.Further checks: