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

Add blit support and fix documentation #22

Merged
merged 5 commits into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
9 changes: 4 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,10 @@ Here are parameters of the **ScaleBar** class constructor.
* ``dimension``: dimension of *dx* and *units*.
It can either be equal

* ``SI_LENGTH``: scale bar showing km, m, cm, etc.
* ``IMPERIAL_LENGTH``: scale bar showing in, ft, yd, mi, etc.
* ``SI_LENGTH_RECIPROCAL``: scale bar showing 1/m, 1/cm, etc.
* ``PIXEL_LENGTH``: scale bar showing px, kpx, Mpx, etc.
* a ``matplotlib_scalebar.dimension._Dimension`` object
* ``si-length``: scale bar showing km, m, cm, etc.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree this was confusing. SI_LENGTH actually refers to a module variable, which could have been imported along the ScaleBar class, but you are write I am sure most people uses the string.

* ``imperial-length``: scale bar showing in, ft, yd, mi, etc.
* ``si-length-reciprocal``: scale bar showing 1/m, 1/cm, etc.
* ``pixel-length``: scale bar showing px, kpx, Mpx, etc.

* ``label``: optional label associated with the scale bar
(default: ``None``, no label is shown)
Expand Down
16 changes: 9 additions & 7 deletions matplotlib_scalebar/scalebar.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ class ScaleBar(Artist):
'center': 10,
}

def __init__(self, dx, units='m', dimension=SI_LENGTH, label=None,
def __init__(self, dx, units='m', dimension='si-length', label=None,
length_fraction=None, height_fraction=None,
location=None, pad=None, border_pad=None, sep=None,
frameon=None, color=None, box_color=None, box_alpha=None,
scale_loc=None, label_loc=None, font_properties=None,
label_formatter=None, fixed_value=None, fixed_units=None):
label_formatter=None, fixed_value=None, fixed_units=None,
use_blit=False):
ericpre marked this conversation as resolved.
Show resolved Hide resolved
"""
Creates a new scale bar.

Expand All @@ -139,11 +140,10 @@ def __init__(self, dx, units='m', dimension=SI_LENGTH, label=None,

:arg dimension: dimension of *dx* and *units*.
It can either be equal
* ``:const:`SI_LENGTH```: scale bar showing km, m, cm, etc.
* ``:const:`IMPERIAL_LENGTH```: scale bar showing in, ft, yd, mi, etc.
* ``:const:`SI_LENGTH_RECIPROCAL```: scale bar showing 1/m, 1/cm, etc.
* ``:const:`PIXEL_LENGTH```: scale bar showing px, kpx, Mpx, etc.
* a :class:`matplotlib_scalebar.dimension._Dimension` object
* ``:const:`si-length```: scale bar showing km, m, cm, etc.
* ``:const:`imperial-length```: scale bar showing in, ft, yd, mi, etc.
* ``:const:`si-length-reciprocal```: scale bar showing 1/m, 1/cm, etc.
* ``:const:`pixel-length```: scale bar showing px, kpx, Mpx, etc.
:type dimension: :class:`str` or
:class:`matplotlib_scalebar.dimension._Dimension`

Expand Down Expand Up @@ -251,6 +251,7 @@ def __init__(self, dx, units='m', dimension=SI_LENGTH, label=None,
self.font_properties = font_properties
self.fixed_value = fixed_value
self.fixed_units = fixed_units
self.use_blit = use_blit
ericpre marked this conversation as resolved.
Show resolved Hide resolved

def _calculate_best_length(self, length_px):
dx = self.dx
Expand Down Expand Up @@ -379,6 +380,7 @@ def _get_value(attr, default):
box.patch.set_color(box_color)
box.patch.set_alpha(box_alpha)
box.draw(renderer)
self.set_animated(self.use_blit)

def get_dx(self):
return self._dx
Expand Down