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

Implement multi-function plotting options in plot() #12962

Closed
alauve opened this issue May 17, 2012 · 86 comments
Closed

Implement multi-function plotting options in plot() #12962

alauve opened this issue May 17, 2012 · 86 comments

Comments

@alauve
Copy link

alauve commented May 17, 2012

The code plot([x,x^2],-.2,2) is a nice shortcut for plotting both x and x!^ 2 on the same graph. However, if you want to choose different colors or linestyles for each function, then it seems you have to execute, e.g.,

p1=plot(x,-.2,1.2,color='blue',linestyle='dotted'); 
p2=plot(x^2,-.2,1.2,color='red',linestyle='dashed'); 
p1+p2

Here is how Maple and Mathematica handle this issue, respectively:

It seems that the keyword 'fill' allows for a dictionary input, so perhaps the relevant code there could serve as a template?

[> plot([x, x^2], x= -.2..1.2, color=["blue", "red"],linestyle=[dot, longdash]);

In[1]:= Plot[{x, x^2}, {x, -.2, 1.2}, PlotStyle -> {{Blue, Dotted}, {Red, Dashed}}]

Remarks:

  1. distinct choices for the curves should be made automatically for the user. Running, e.g.,
In[1]:= Plot[{x, x^2}, {x, -.2, 1.2}]

in Mathematica produces two curves that are not both solid-blue.

  1. the functionality for fillcolor, color, and fill should be the same insofar as possible.

CC: @kcrisman @ppurka @jdemeyer @jasongrout @saliola @sagetrac-jhonrubia6 @paulmasson @novoselt

Component: user interface

Keywords: plot, linestyle, color

Author: Aaron Lauve

Branch/Commit: 4acb9d6

Reviewer: Paul Masson

Issue created by migration from https://trac.sagemath.org/ticket/12962

@alauve alauve added this to the sage-5.11 milestone May 17, 2012
@jdemeyer jdemeyer modified the milestones: sage-5.11, sage-5.12 Aug 13, 2013
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.1, sage-6.2 Jan 30, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.2, sage-6.3 May 6, 2014
@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@alauve

This comment has been minimized.

@alauve alauve modified the milestones: sage-6.4, sage-6.8 Jul 1, 2015
@alauve
Copy link
Author

alauve commented Jul 4, 2015

@alauve
Copy link
Author

alauve commented Jul 13, 2015

Commit: d169dc1

@alauve
Copy link
Author

alauve commented Jul 13, 2015

comment:7

I've pushed a possible solution and set the ticket to 'needs_review'.

Comments?


New commits:

d169dc1Started adding multiple directives for color and linestyle to _plot()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 13, 2015

Changed commit from d169dc1 to 2fb9172

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 13, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

58f8323multi-function plotting now allows for and to be dictionaries/lists/tuples. Similar functionality added for and .
2fb9172deleted superfluous whitespace

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Changed commit from 2fb9172 to d02567e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

d02567emade plot-curve colors uniform, for ease of deciphering in lieu of a legend, when plot() is called with multiple functions.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

c6ed638removed sphinx_plot calls, as I wasn't sure how to get them to work with doctests. (hope to put them back eventually.)
ded1039added some sphinx_plot calls

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Changed commit from d02567e to ded1039

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Changed commit from ded1039 to f93aaf3

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

f93aaf3Merge branch 'develop' into t/12962/implement_multi_function_plotting_options_in_plot__

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Branch pushed to git repo; I updated commit sha1. New commits:

c9b1aa4fixed a typo

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 20, 2015

Changed commit from f93aaf3 to c9b1aa4

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Aug 11, 2016

comment:52

Doctests pass. Documentation builds and looks good as is.

Aaron, are you still planning to work on plots on this ticket or can I set positive review?

@alauve
Copy link
Author

alauve commented Aug 11, 2016

comment:53

Hmm,
Looking over the documentation, I see a few minor changes that I should make. I'll toggle back to needs_work. When you see it return to needs_review, I'm done.

Thx.

Replying to @paulmasson:

Doctests pass. Documentation builds and looks good as is.

Aaron, are you still planning to work on plots on this ticket or can I set positive review?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 11, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

26ac1d3added a few more sphinx_plots; better described how default colors are chosen

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 11, 2016

Changed commit from 165dda5 to 26ac1d3

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Aug 11, 2016

comment:57

Aaron, you added a bit more that what's in your description: the options for legend_color are expanded which is good and functions as expected.

Regarding legends, for the case of multiple graph colors with a single legend_label, I find the empty spaces in the legend unexpected. Wouldn't it make more sense to repeat the single label for all lines? If I'm graphing multiple functions and deliberately give one label, I'd expect it to appear for all of them.

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Aug 11, 2016

comment:58

Also, the documentation for legend_color and fillcolor says that they follow the same conventions as color. That's not completely true, since the default for legend_color is black and the default for fillcolor is gray. Please add those defaults for clarity.

@alauve
Copy link
Author

alauve commented Aug 11, 2016

comment:59

Replying to @paulmasson:

Aaron, you added a bit more that what's in your description: the options for legend_color are expanded which is good and functions as expected.

ah yes... it occurred to me that this was a natural extension of what was asked for in [comment:16]. My apologies for not mentioning it.

Regarding legends, for the case of multiple graph colors with a single legend_label, I find the empty spaces in the legend unexpected. Wouldn't it make more sense to repeat the single label for all lines? If I'm graphing multiple functions and deliberately give one label, I'd expect it to appear for all of them.

I don't know that I agree. I was trying to think of all the reasons I'd just include one label... "trig functions" or "cos(nx)" or some such. I don't think I'd want to see that written multiple times. Certainly, seeing "f" or "x2" written multiple times would be silly. But, it is nearly as easy to write ["trig functions", "", ""] as it is to write "trig functions", so I'm happy to modify the code accordingly.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 12, 2016

Changed commit from 26ac1d3 to 742422e

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 12, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

742422eModified behavior of fillcolor and legend_label, and reworked some of the sphinx_plot examples as well.

@paulmasson
Copy link
Mannequin

paulmasson mannequin commented Aug 12, 2016

comment:61

Good to go.

@paulmasson paulmasson mannequin modified the milestones: sage-7.3, sage-7.4 Aug 12, 2016
@vbraun
Copy link
Member

vbraun commented Aug 13, 2016

Changed commit from 742422e to none

@vbraun
Copy link
Member

vbraun commented Aug 13, 2016

comment:62

Branch seems to be missing?

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 13, 2016

Branch pushed to git repo; I updated commit sha1. Last 10 new commits:

276f8ebMerge branch 'u/alauve/implement_multi_function_plotting_options_in_plot__' of trac.sagemath.org:sage into public/graphics/multi_function_plot_options-12962
02f19a2Made default color choices when plot() is passed a list of functions.
590325edoctests pass; ValueError check works if color and rgbcolor are both passed; errors remain in building documentation
7d593cdremoved whitespace around keyword calls
c836728working toward request to use rgbcolor instead of color. Simply making this change in L2139 breaks the plot()
dc15618documentation now builds. problem was attempting to set frame and axes options in graphics_array with sphinx_plot.
165dda5cleaned up a few comments; deleted others no longer needed
26ac1d3added a few more sphinx_plots; better described how default colors are chosen
742422eModified behavior of fillcolor and legend_label, and reworked some of the sphinx_plot examples as well.
4acb9d6Merge branch 'public/graphics/multi_function_plot_options-12962' of trac.sagemath.org:sage into public/graphics/multi_function_plot_options-12962

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 13, 2016

Commit: 4acb9d6

@tscrim
Copy link
Collaborator

tscrim commented Aug 13, 2016

comment:64

Hmm...strange. I have the most recent copy, so I've pushed it back.

@vbraun
Copy link
Member

vbraun commented Aug 14, 2016

Changed branch from public/graphics/multi_function_plot_options-12962 to 4acb9d6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants