Skip to content
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

refactoring the plotting system #166

Merged
merged 49 commits into from
Jun 4, 2021
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
c76da0e
started working on better plot system.
wpfff Jun 23, 2020
154f909
merge from main repo.
wpfff Nov 25, 2020
27462a3
added some basic functionality to find config files.
wpfff Dec 3, 2020
3f18cdd
small fix: allow passing of keyword arguments from the command line.
wpfff Dec 3, 2020
491a128
[WIP] started to move matplotlib helper functions around.
wpfff Dec 3, 2020
ea93db1
fix: don't import from lower level module on import to avoid circular…
wpfff Dec 3, 2020
08a0025
added stylefile where we can easily find it.
wpfff Dec 3, 2020
fa6c6f8
moved things up a level that are basically plotting backend-independent.
wpfff Dec 3, 2020
80ee2ac
moved widgets that use MPL but are higher-level than autoplot into here.
wpfff Dec 3, 2020
0cc7b6b
[WIP] first steps and in modified autoplot using matplotlib. so far o…
wpfff Dec 3, 2020
97a9230
merge from remote master.
wpfff Dec 3, 2020
fabaa76
Merge branch 'master' into betterplotting
wpfff Jan 3, 2021
e92bd1b
Merge branch 'master' into betterplotting
wpfff Apr 22, 2021
990c00f
some better organization:
wpfff Apr 23, 2021
29d1e9b
clarifying better which objects are responsible for what:
wpfff Apr 24, 2021
3f589a1
re-enabled basic colorplotting.
wpfff Apr 24, 2021
d79fcbf
fixed type hints in plotting.py
wpfff Apr 24, 2021
45ee82d
fixing more typing annotations for mypy.
wpfff Apr 24, 2021
6d845e1
more cleanup for mypy.
wpfff Apr 24, 2021
c7669d1
more cleanup for mypy.
wpfff Apr 24, 2021
dfeccd5
more cleanup for mypy.
wpfff Apr 24, 2021
159a82e
more cleanup for mypy.
wpfff Apr 24, 2021
3c0ab02
emit windowClosed signal for all PlotWindow objects.
wpfff Apr 25, 2021
dcc09fa
improved testing of the autoplot app.
wpfff Apr 25, 2021
3984dbd
fixed tests to work with latest changes on FigureMaker.
wpfff Apr 25, 2021
0ff7382
- make sure we plot in the correct panels when plotting complex data …
wpfff Apr 25, 2021
0663751
minor fixes and aesthetic improvements
wpfff Apr 25, 2021
9980c30
Updated docs for the base plotting module.
wpfff Apr 25, 2021
0a70e4c
minor fixes (broken links).
wpfff Apr 25, 2021
4451121
completed docs for plotting modules.
wpfff Apr 26, 2021
338494c
added font scaling for high-dpi.
wpfff Apr 26, 2021
2fb7265
Full complex options buttons
FarBo Apr 27, 2021
539c068
- fix plotting of Real part only
wpfff Apr 28, 2021
1498973
reimplemented dpi scaling in all widgets and copying meta info.
wpfff Apr 29, 2021
acb0e8d
make sure meta entries don't get too long when copying.
wpfff Apr 30, 2021
a6a69f9
don't inherit from object.
wpfff Apr 30, 2021
f01cf40
- added central method for scaling dpi
wpfff May 2, 2021
5523567
change back to bigger icons in the toolbar
wpfff May 11, 2021
1ec2d6a
fixed a couple of mypy issues.
wpfff May 11, 2021
a792928
more mypy fixing.
wpfff May 11, 2021
2ab1ca6
Add disappeared "imported plottr version" log message
astafan8 May 31, 2021
90e3dc8
Merge branch 'master' into betterplotting
astafan8 Jun 1, 2021
a9ef0f0
importing config files without modifying sys.path.
wpfff Jun 3, 2021
6f3cb98
clarify why `formatSubPlot` does not raise an error when not reimplem…
wpfff Jun 3, 2021
1d09196
fix mypy issue with importlib.
wpfff Jun 3, 2021
c12e508
Update plottr/plot/mpl/widgets.py
wpfff Jun 4, 2021
5359ee4
enforcing real in a more sane spot.
wpfff Jun 4, 2021
8622f9c
Merge remote-tracking branch 'origin/betterplotting' into betterplotting
wpfff Jun 4, 2021
ba44f82
fix typing.
wpfff Jun 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions plottr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, List, Tuple
import os

if TYPE_CHECKING:
Expand All @@ -14,8 +14,37 @@
Flowchart = pgFlowchart
NodeBase = pgNode

plottrPath = os.path.split(os.path.abspath(__file__))[0]

from ._version import get_versions
__version__ = get_versions()['version']
del get_versions

plottrPath = os.path.split(os.path.abspath(__file__))[0]


def configPaths() -> Tuple[str, str, str]:
"""Get the folders where plottr looks for config files.

:return: List of absolute paths, in order of priority:
(1) current working directory
(2) ~/.plottr
(3) config directory in the package.
"""
builtIn = os.path.join(plottrPath, 'config')
user = os.path.join(os.path.expanduser("~"), '.plottr')
cwd = os.getcwd()
return cwd, user, builtIn


def configFiles(fileName: str) -> List[str]:
"""Get available config files with the given file name.

:param fileName: file name, without path
:return: List of found config files with the provided name, in order
or priority.
"""
ret = []
for path in configPaths():
fp = os.path.join(path, fileName)
if os.path.exists(fp):
ret.append(fp)
return ret
28 changes: 28 additions & 0 deletions plottr/config/plottr_default.mplstyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
axes.grid: True
axes.prop_cycle: cycler('color', ['1f77b4', 'ff7f0e', '2ca02c', 'd62728', '9467bd', '8c564b', 'e377c2', '7f7f7f', 'bcbd22', '17becf'])

figure.dpi: 150
figure.figsize: 4.5, 3

font.size: 6
font.family: Helvetica, Arial, DejaVu Sans, Bitstream Vera Sans

grid.linewidth: 0.5
grid.linestyle: --

image.cmap: magma

legend.fontsize: 6
legend.frameon: True
legend.numpoints: 1
legend.scatterpoints: 1

lines.marker: o
lines.markersize: 3
lines.markeredgewidth: 1
lines.markerfacecolor: w
lines.linestyle: -
lines.linewidth: 1

savefig.dpi: 300
savefig.transparent: False
15 changes: 10 additions & 5 deletions plottr/gui/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .tools import dictToTreeWidgetItems
from plottr import QtCore, Flowchart, QtWidgets, Signal, Slot
from plottr.node import Node, linearFlowchart
from ..plot import PlotNode, PlotWidgetContainer, MPLAutoPlot
from ..plot import PlotNode, PlotWidgetContainer, PlotWidget

__author__ = 'Wolfgang Pfaff'
__license__ = 'MIT'
Expand Down Expand Up @@ -74,15 +74,20 @@ class PlotWindow(QtWidgets.QMainWindow):
:meth:`addNodeWidgetFromFlowchart`.
"""

plotWidgetClass = MPLAutoPlot

def __init__(self, parent: Optional[QtWidgets.QMainWindow] = None,
fc: Optional[Flowchart] = None, **kw: Any):
fc: Optional[Flowchart] = None,
plotWidgetClass: Optional[Any] = None,
**kw: Any):
super().__init__(parent)

if plotWidgetClass is None:
from ..plot.mpl import AutoPlot
plotWidgetClass = AutoPlot

self.plotWidgetClass = plotWidgetClass
self.plot = PlotWidgetContainer(parent=self)
self.setCentralWidget(self.plot)
self.plotWidget: Optional[MPLAutoPlot] = None
self.plotWidget: Optional[PlotWidget] = None

self.nodeToolBar = QtWidgets.QToolBar('Node control', self)
self.addToolBar(self.nodeToolBar)
Expand Down
4 changes: 2 additions & 2 deletions plottr/plot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .base import PlotNode, PlotWidgetContainer, makeFlowchartWithPlot
from .mpl import AutoPlot as MPLAutoPlot
from .base import PlotNode, PlotWidgetContainer, makeFlowchartWithPlot, \
PlotWidget
Loading