Skip to content

Commit

Permalink
Consistent markers (#34)
Browse files Browse the repository at this point in the history
* extracted marker and line styles

* figure uses styles from draw module

* added more linestyles

* updated changelog
  • Loading branch information
CDonnerer committed Feb 15, 2021
1 parent 82b19b1 commit 40062f2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Changelog
=========

Version 0.2.1
---------------
- Fixed bug to allow legend with non-unique labels
- Moved line and marker styles options into drawing module

Version 0.2.0
---------------
- Added object-orientated figure API, entailed major refactor of plotting code
Expand Down
17 changes: 6 additions & 11 deletions src/shellplot/drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,20 @@
from collections import namedtuple
from typing import List

MARKER_STYLES = {1: "+", 2: "*", 3: "o", 4: "x", 5: "@", 6: "■"}

LINE_STYLES = {10: "·", 11: ":", 12: "÷", 13: "×"}

PALETTE = {
# empty space
0: " ",
# scatter points
1: "+",
2: "*",
3: "o",
4: "x",
5: "@",
6: "■",
# line drawing
10: "·",
11: ":",
# bar drawing
20: "|",
21: "_",
22: "-",
23: "┐",
}
PALETTE.update(MARKER_STYLES)
PALETTE.update(LINE_STYLES)

LegendItem = namedtuple("LegendItem", ["symbol", "name"])

Expand Down
6 changes: 3 additions & 3 deletions src/shellplot/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from shellplot._config import _global_config as config
from shellplot._plotting import PlotCall, Plotter, _barh, _boxplot, _hist, _plot
from shellplot.axis import Axis
from shellplot.drawing import draw
from shellplot.drawing import LINE_STYLES, MARKER_STYLES, draw
from shellplot.utils import get_index, numpy_1d, numpy_2d, remove_any_nan


Expand Down Expand Up @@ -68,8 +68,8 @@ def clear(self):
def _init_figure_elements(self):
self.canvas = np.zeros(shape=(self.figsize[0], self.figsize[1]), dtype=int)
self.legend = list()
self.markers = cycle([1, 2, 3, 4, 5, 6])
self.lines = cycle([10, 11])
self.markers = cycle(MARKER_STYLES.keys())
self.lines = cycle(LINE_STYLES.keys())

def plot(self, x, y, color=None, **kwargs):
"""Plot x versus y as scatter.
Expand Down

0 comments on commit 40062f2

Please sign in to comment.