[Matplotlib-devel] What is draw_path's transform's destination?

Thomas Caswell tcaswell at gmail.com
Sun Mar 31 00:12:21 EDT 2019


The transform is from whatever coordinates the path is in to pixels.

>From skimming the code on `Line2D` (and from the name) it looks like it is
only the affine part of the path transformation.

Looking at the method `_offset_transform` in the base class also supports
the target coordinate system of the transform is pixels.

That is a pretty nifty tool, is it going to end up someplace public when
you are done?

Tom

On Sat, Mar 30, 2019 at 6:44 PM Rob McDonald <rob.a.mcdonald at gmail.com>
wrote:

> I'm implementing a custom path effect by inheriting from
> AbstractPathEffect and implementing draw_path as instructed here
> <https://matplotlib.org/api/patheffects_api.html#matplotlib.patheffects.AbstractPathEffect.draw_path>.
> That link references RenderBase.draw_path
> <https://matplotlib.org/api/backend_bases_api.html#matplotlib.backend_bases.RendererBase.draw_path> to
> define the required interface.  Unfortunately, I can't find anywhere in the
> associated documentation that tells me what the transform argument really
> entails.
>
> I've also read the transforms tutorial
> <https://matplotlib.org/tutorials/advanced/transforms_tutorial.html>, and
> while that explains the pipeline and all the intermediate transformations,
> it doesn't really settle what I have available to me in draw_path.  It is
> clear that I can use it to transform coordinates from data to something --
> but I don't know what to.
>
> For the big picture -- I am implementing a path effect to allow drawing
> hatched lines similar to this
> <https://www.mathworks.com/matlabcentral/fileexchange/29121-hatched-lines-and-contours>,
> which I did years ago in Matlab.  Years before that, I've also done this in
> Java Graphics2D by implementing a custom stroke.  (The Java approach is
> more applicable to the path effect approach, but I can't point to that code
> online anywhere.)
>
> Anyway, I have things mostly working -- and I am using the transform to go
> from data coordinates to something that looks orthogonal and reasonable
> on-screen.  So, for minimum functionality, it works.  However, I want to
> give the user the ability to control the length and spacing of the hatches
> -- which is in a coordinate system after the transformation is applied.
> So, in order to document this thing, I need to know what it is.  Or, if
> there is a way to get intermediate stages of the transformation pipeline,
> that would work too.
>
> As for the user interface -- it seems to make the most sense to specify
> the hatch length and spacing in terms of something similar to a line width
> (typically points) or a marker size.  I'm new to Python and matplotlib --
> what is the Pythonic unit a user would expect to specify this in (and how
> do I achieve that with what is available in draw_path)?
>
> Thanks,
>
> Rob
> _______________________________________________
> Matplotlib-devel mailing list
> Matplotlib-devel at python.org
> https://mail.python.org/mailman/listinfo/matplotlib-devel
>


-- 
Thomas Caswell
tcaswell at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-devel/attachments/20190331/b700c13a/attachment.html>


More information about the Matplotlib-devel mailing list