Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
qutil
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
qutech
qutil
Commits
1cd9231e
Commit
1cd9231e
authored
2 years ago
by
Tobias Hangleiter
Browse files
Options
Downloads
Patches
Plain Diff
Add list_styles
parent
91ee58d1
No related branches found
No related tags found
1 merge request
!67
Add matplotlib stylesheets
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
qutil/plotting/core.py
+33
-1
33 additions, 1 deletion
qutil/plotting/core.py
with
33 additions
and
1 deletion
qutil/plotting/core.py
+
33
−
1
View file @
1cd9231e
import
dataclasses
import
pathlib
import
warnings
from
contextlib
import
contextmanager
from
typing
import
Sequence
,
Tuple
,
Mapping
,
Any
,
Union
from
typing
import
Sequence
,
Tuple
,
Mapping
,
Any
,
Union
,
List
from
weakref
import
WeakValueDictionary
import
matplotlib
as
mpl
...
...
@@ -18,6 +19,7 @@ __all__ = [
"
plot_2d_dataframe
"
,
"
cycle_plots
"
,
"
update_plot
"
,
"
list_styles
"
,
"
get_rwth_color_cycle
"
,
"
rwth_color_cycle
"
,
"
rwth_color_cycle_25
"
,
...
...
@@ -373,6 +375,36 @@ rwth_color_cycle_100 = get_rwth_color_cycle(1)
rwth_color_cycle
=
rwth_color_cycle_100
def
list_styles
(
include_matplotlib_styles
:
bool
=
False
)
->
List
[
str
]:
"""
List available matplotlib styles.
Parameters
----------
include_matplotlib_styles : bool, default False
Include the default styles that ship with ``matplotlib`` as well
as the custom styles in the matplotlib config directory. If
False, only the custom styles defined in this module are
listed.
Returns
-------
styles : list[str]
The styles such that ``plt.style.use(style)`` works for all
``style`` in ``styles``.
"""
custom_styles
=
[]
root_path
=
pathlib
.
Path
(
__file__
).
parents
[
1
]
for
file
in
(
root_path
/
'
plotting
'
).
glob
(
'
*.mplstyle
'
):
file
=
file
.
relative_to
(
root_path
.
parent
)
style
=
'
.
'
.
join
(
file
.
parent
.
parts
+
(
file
.
stem
,))
custom_styles
.
append
(
style
)
if
include_matplotlib_styles
:
return
plt
.
style
.
available
+
custom_styles
else
:
return
custom_styles
@dataclasses.dataclass
class
LaTeXPlotHelper
:
A4_SIZE_INCHES
=
(
8.25
,
11.75
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment