Opened 8 years ago

Last modified 4 years ago

#15903 new defect

Allow implicit (and contour, region?) plots to have legend

Reported by: kcrisman Owned by:
Priority: major Milestone: sage-6.4
Component: graphics Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


See this sage-support thread.

var('x y')
P = contour_plot(x^2+y^2==1,(x,-1,1),(y,-1,1),plot_points=150, contours=(0,0), fill=False, cmap=["blue"],legend_label='test')
print P.legend()
print P.legend()
print P[0].options()['legend_label']

We see that legends aren't set.

In fact, the mpl contour api seems to confirm that we shouldn't be trying to label contour plots with legends. (Which makes sense, since they have their own labeling mechanism). However, for implicit plots, this might cause a problem. A workaround like at the bottom of this example

artists, labels = cs.legend_elements()
plt.legend(artists, labels, handleheight=2)

which extracts the labels from the contour legend and then puts them into the usual legend might be a solution.

Change History (4)

comment:1 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.2 to sage-6.3

comment:2 Changed 7 years ago by vbraun_spam

  • Milestone changed from sage-6.3 to sage-6.4

comment:3 Changed 5 years ago by kcrisman

Noting that this is still a valid bug - just came up in a colleague's question.

Note: See TracTickets for help on using tickets.