-
Notifications
You must be signed in to change notification settings - Fork 120
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
Use theme instead of several optional parameters for general_plotter #425
Comments
No issue here. I appreciate the inputs because it's helping drive the direction. I can't guarantee I'll get back to all these issues quickly due to the volume of demands.
Theme can be set with https://docs.pyvista.org/examples/02-plot/themes.html
Quite true. We do this a little bit by default with: Which is called on init of pymapdl. Changes need to be made module-wide to ensure that we're not overriding the theme with each method. |
I found that one. But I couldn't find anything to set a user defined theme. And I'm also not sure, which way would be the best to do it (at least I guess for now it doesn't matter whether its implemented in pyvista or pymapdl). Basicaly I see two options (there might be more):
Thats also something I thought about. Its quite tricky. I see two different approaches here too.
If themes are implemented as a class, it might be worth to consider implementing a functionallity, which saves all the original rcParams-values before setting new ones and add a method Another alternative would be some kind of stylesheet-class, which only formats a given plot (without touching rcParams). That could be given as a parameter to a plot-function. If None, the plot-functions would fall back to the theme. |
class Theme():
"""Control the default plotting theme for ``pyvista``"""
def __init__():
self._background = [0.3, 0.3, 0.3]
@property
def background(self):
"""Default background color of a pyvista plot.
Examples
--------
Set the default global background of all plots to white.
>>> pyvista.theme.background = 'white'
"""
return self._background
@background.setter
def background(self, new_background):
self._background = parse_color(new_background) This is preferable as we can incorporate some basic type checking when setting these values, rather than from a dictionary where the properties are not apparent in an IDE via code completion. |
@akaszynski I guess it will take a while until the new Theme-class becomes availeable in a new pyvista release, and afterwards in a new release of pymapdl. If you don't plan to implement it right away in pymapdl (I can't match your speed ^^), I would start to gather the different places where pymapdl is setting plot-format in a plotting_themes.py using the new pyvista themes over the weekend. Might help when deciding how to restructure pymapdl to use themes. |
I think this feature warrants a quick release as it's a critical feature for modules that rely on pyvista. I'll try to push one out soon, potentially over the weekend. |
I have looked into the default APDL plotting functions. Here is a summary plotting_themes.py The short version:
There are a lot of pymapddl-specific parameters. The question here is, if we add this to a |
In |
Even if we do not implement it this way, it might be a good testing solution without messing with the old interface. If this wotks as expected, its easy to transfer to the |
That needs to be implemented. I'm going to make a hefty PR to patch plotting along with using the theme Class just merged with |
Can this issue be closed? It looks like it might have been resolved? |
This needs pyvista/pyvista#1359 then a new PR that implements a theme. |
PR #477 |
What additional kwargs/attributes do we need to add to |
I'm not sure if we need it (thats up for discussion imho). In the summary about plotting functions, I found many parameters that are not part of pyvista Theme, and might be added to MapdlTheme (or maybe not ^^).
Interesting might be e.g. |
This probably goes in line with making plotting an external library where the plotting is made by a class. Or maybe we just need to call pyvista........ |
In #1938 we allow to pass more arguments to Pyvista object. It should alleviate the problem of customising plots. |
Edit: Progress
plot_nodal...
->plot(solution: NodalSolution)
It might be useful, to make second and third part into new issues.
EndEdit
Sorry for spamming issues, but as I play with the plot functionality (including pyvista, which is also new for me), I get a lot of ideas ^^
There are many parameters to change the look of plots, and also some missing parameters (e.g. to change label format). Even worse, by setting some of these to default values, its not possible to use pyvista themes like 'document' or 'night' without "removing" those default values (by setting parameters to
''
). Lables can't be changed at all.I think it would be better to use a Theme to format most of the plot. It would be much cleaner and easier to use. Up till now I didn't find, how to use/add a custom theme with pyvista. But it seems like a simple dict to me - so it should be easy to add for pyvista, if it is really not implemented yet.
The text was updated successfully, but these errors were encountered: