Ask Your Question
0

`legend_label` for 2d scatter plot

asked 2024-09-06 17:08:38 +0200

seewoo5 gravatar image

updated 2024-09-08 07:05:24 +0200

Emmanuel Charpentier gravatar image

I could not find legend_label option for 2d scatter plot, and it seems not exist. Is this true? If it is, any possible reason for this? I checked the code on github (here)[https://github.com/sagemath/sage/blob/24698e7e7ec08c821961f6c2236f7069b0489302/src/sage/plot/scatter_plot.py#L23].

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2024-09-08 07:39:34 +0200

Emmanuel Charpentier gravatar image

An example of what you aim to do would be useful : your question doesn't specify if you want to label the series of a (composite) plot of of multiple set of points,or label each point individually (e. g. by its coordinates).

The latter case is best manager by using point2d (resp. point3d), which has a legend_label option.

The former case isn't handled by Sage directly. You have to manage it yourself. A couple of options :

  • You may overlay (sum) a set of scatter_plots and a a suitably designed legend using point2d and text2d (resp. text3d) objects ;

  • You may also set your (sum of) point2ds and your legend in a multi_graphics object.

If you don't need to further modify the resulting graph, an alternative is to use some R function (either basic plot(..., type="p"), a trellis plot or a ggplot2 object) ; this lazy solution gives you the zillion options used by applied statisticians for their scatter plots, which are a basic need for them. Howver, giving such graphs the same "look and feel" than those created by Sage may require some work...

You may also roll up your own matplotlib function, ou directly use some predefined function of this (rich) library.

HTH,

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2024-09-06 17:08:38 +0200

Seen: 135 times

Last updated: Sep 08