FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make hatch linewidth an rcParam by mdboom · Pull Request #6198 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension .cpp  (1) .h  (2) .mplstyle  (1) .png  (8) .py  (5) .template  (1) All 6 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
Next Next commit
Make hatch linewidth an rcParam
  • Loading branch information
mdboom committed Mar 23, 2016
commit 3b2e7e9a4bd21628cd9ddea18ed823ee5ee52719
7 changes: 7 additions & 0 deletions lib/matplotlib/backend_bases.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,7 @@ def __init__(self):
self._linewidth = 1
self._rgb = (0.0, 0.0, 0.0, 1.0)
self._hatch = None
self._hatch_linewidth = rcParams['hatch.linewidth']
self._url = None
self._gid = None
self._snap = None
Expand Down Expand Up @@ -1111,6 +1112,12 @@ def get_hatch_path(self, density=6.0):
return None
return Path.hatch(self._hatch, density)

def get_hatch_linewidth(self):
"""
Gets the linewidth to use for hatching.
"""
return self._hatch_linewidth

def get_sketch_params(self):
"""
Returns the sketch parameters for the artist.
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_pdf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1182,7 +1182,7 @@ def writeHatches(self):
0, 0, sidelen, sidelen, Op.rectangle,
Op.fill)

self.output(0.1, Op.setlinewidth)
self.output(rcParams['hatch.strokewidth'], Op.setlinewidth)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

should this be hatch.linewidth?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Indeed. Will fix. Puzzled by why that didn't raise an exception.


# TODO: We could make this dpi-dependent, but that would be
# an API change
Expand Down
3 changes: 2 additions & 1 deletion lib/matplotlib/backends/backend_ps.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ def create_hatch(self, hatch):
if hatch in self._hatches:
return self._hatches[hatch]
name = 'H%d' % len(self._hatches)
linewidth = rcParams['hatch.linewidth']
self._pswriter.write("""\
<< /PatternType 1
/PaintType 2
Expand All @@ -313,7 +314,7 @@ def create_hatch(self, hatch):

/PaintProc {
pop
0 setlinewidth
%(linewidth)f setlinewidth
""" % locals())
self._pswriter.write(
self._convert_path(Path.hatch(hatch), Affine2D().scale(72.0),
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_svg.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def _write_hatches(self):
style=generate_css({
'fill': rgb2hex(stroke),
'stroke': rgb2hex(stroke),
'stroke-width': '1.0',
'stroke-width': rcParams['hatch.linewidth'],
'stroke-linecap': 'butt',
'stroke-linejoin': 'miter'
})
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/mpl-data/stylelib/classic.mplstyle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ patch.facecolor : b
patch.edgecolor : k
patch.antialiased : True # render patches in antialiased (no jaggies)

hatch.linewidth : 1.0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Did we have 3 (!) different default values for this before?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Actually 4, since SVG was "1 point" and Agg was "1 pixel". We could try to emulate that old brokenness if we want (I guess).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

No, I think unify on one is an ok complete break. We should at least document what the old values were. On the off chance we get someone who really cares, they likely only care on one backend (or we would have heard from them sooner!).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Agreed. I've documented the old values in the style changes what's new.


hist.bins : 10

### FONT
Expand Down
3 changes: 3 additions & 0 deletions lib/matplotlib/rcsetup.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,9 @@ def validate_animation_writer_path(p):
'patch.facecolor': ['#1f77b4', validate_color], # blue (first color in color cycle)
'patch.antialiased': [True, validate_bool], # antialiased (no jaggies)

## hatch props
'hatch.linewidth': [1.0, validate_float],

## Histogram properties
'hist.bins': [10, validate_hist_bins],

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Viewer requires iframe.
3 changes: 3 additions & 0 deletions matplotlibrc.template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ backend : $TEMPLATE_BACKEND
#patch.edgecolor : black
#patch.antialiased : True # render patches in antialiased (no jaggies)

### HATCHES
#hatch.linewidth : 1.0

### Boxplot
#boxplot.notch : False
#boxplot.vertical : True
Expand Down
2 changes: 1 addition & 1 deletion src/_backend_agg.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ RendererAgg::_draw_path(path_t &path, bool has_clippath, const facepair_t &face,
hatch_path_trans_t hatch_path_trans(hatch_path, hatch_trans);
hatch_path_curve_t hatch_path_curve(hatch_path_trans);
hatch_path_stroke_t hatch_path_stroke(hatch_path_curve);
hatch_path_stroke.width(1.0);
hatch_path_stroke.width(points_to_pixels(gc.hatch_linewidth));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

so, here in AGG we have the graphics context holding this new parameter, but in the vector backends we don't use the graphics context for that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yes -- the C++ side can not access rcParams directly, so we have to stuff it somewhere to pass to _backend_agg.so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

There is no public API to change the hatch yet and it looks like vector backends do not have the proper hooks set up for the relevant functions to have a reference to the gc.

hatch_path_stroke.line_cap(agg::square_cap);

// Render the path into the hatch buffer
Expand Down
1 change: 1 addition & 0 deletions src/_backend_agg_basic_types.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class GCAgg
e_snap_mode snap_mode;

py::PathIterator hatchpath;
double hatch_linewidth;

SketchParams sketch;

Expand Down
1 change: 1 addition & 0 deletions src/py_converters.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ int convert_gcagg(PyObject *pygc, void *gcp)
convert_from_method(pygc, "get_clip_path", &convert_clippath, &gc->clippath) &&
convert_from_method(pygc, "get_snap", &convert_snap, &gc->snap_mode) &&
convert_from_method(pygc, "get_hatch_path", &convert_path, &gc->hatchpath) &&
convert_from_method(pygc, "get_hatch_linewidth", &convert_double, &gc->hatch_linewidth) &&
convert_from_method(pygc, "get_sketch_params", &convert_sketch_params, &gc->sketch))) {
return 0;
}
Expand Down

Back | FazBrowse Home | New Git URL