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

Updates to matplotlib element references to use opts #3270

Merged
merged 6 commits into from
Dec 11, 2018

Conversation

philippjfr
Copy link
Member

No description provided.

@philippjfr philippjfr added the type: docs Related to the documentation and examples label Dec 10, 2018
@jlstevens
Copy link
Contributor

jlstevens commented Dec 10, 2018

I've gone through the suggestions above and I think my own preference is fairly clear and consistent: if you have a composition and don't need to distinguish identical element types, put .opts at the end and use the opts utility.

I think this has the advantages of:

  1. Consistency
  2. Separating content and presentation (all options at the end)
  3. Allowing people to try out tab-completion in these element reference notebooks.

One thing I would say is maybe opts.defaults is more appropriate for some of these. For instance:

curve = hv.Curve((xs,ys))
arrow = hv.Arrow(0, 5, 'Inflection', 'v')
(curve * arrow).opts(
   opts.Curve(color='#D3D3D3'))

This is in the Arrows notebook but we are customizing Curve? If would be better to show opts.Arrow for something and given we are just changing the color of the curve (for no particularly important reason), I would also consider using opts.defaults(opts.Curve(color='#D3D3D3')) at the top of the notebook instead.

@jbednar
Copy link
Member

jbednar commented Dec 10, 2018

opts.defaults does seem more appropriate in some cases here, yes.

"%%opts QuadMesh [xticks=[10, 100,1000]] QuadMesh.LogScale [logx=True]\n",
"hv.QuadMesh((xs, ys, zs), group='LinearScale') + hv.QuadMesh((xs, ys, zs), group='LogScale')"
"qmesh = hv.QuadMesh((xs, ys, zs), label='Linear Axis')\n",
"log_qmesh = qmesh.relabel('Log x-axis')\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Could use title_format here too...

"hmap = hv.HoloMap({phase: hv.VectorField((x, y,(vector_data[2]+phase)%np.pi*2, vector_data[3]+np.abs(phase)))\n",
" for phase in np.linspace(-np.pi,np.pi,5)}, kdims='Phase')\n",
"\n",
"hmap.opts(opts.VectorField(color='Angle', magnitude=dim('Magnitude').norm()*0.2, rescale_lengths=False))"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would format this consistently i.e start opts.VectorField indented on the next line.

@jlstevens
Copy link
Contributor

Thanks for updating these! I think we are converging on a common style now.

Merging.

@jlstevens jlstevens merged commit d21c1d7 into master Dec 11, 2018
@philippjfr philippjfr deleted the mpl_reference_updates branch December 13, 2018 04:21
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: docs Related to the documentation and examples
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants