ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 20 Sep 2021 00:31:45 +0200Marker color not consistenthttps://ask.sagemath.org/question/59101/marker-color-not-consistent/I have a simple plot with a legend in different colors. The result will be correct or incorrect depending of the order of the graphic elements.
This code gives an incorrect result:
reset()
Plaut = Graphics()
Plaut+=point([1,1/2],color='blue',size=15,legend_label='Sample point', legend_color='blue')
Plaut+=plot(x/2,x,0,2,color='black', thickness=0.2,legend_label='black line', legend_color='black')
Plaut+=plot(-x/2+1,x,0,2,color='red', thickness=0.2,legend_label='red line', legend_color='red')
Plaut.set_legend_options(loc=(1.1,0), markerscale=1)
show(Plaut, title='Color of the marker - 1.')
see ![Marker Color 1](/upfiles/16320897431508949.png)
while this one (the only difference with the first one being the order of the graphic elements) gives a correct result:
reset()
Plaut = Graphics()
Plaut+=plot(x/2,x,0,2,color='black', thickness=0.2,legend_label='black line', legend_color='black')
Plaut+=plot(-x/2+1,x,0,2,color='red', thickness=0.2,legend_label='red line', legend_color='red')
Plaut+=point([1,1/2],color='blue',size=15,legend_label='Sample point', legend_color='blue')
Plaut.set_legend_options(loc=(1.1,0), markerscale=1)
show(Plaut, title='Color of the marker - 2.')
Here, the result is as expected:
![image description](/upfiles/16320900833480936.png)
For this MWE the correction was easy but when I have a lot of elements it is time consuming and somewhat frustrating to manually find the right configuration. I did not find in the manual a rule to follow to directly get the correct result.c05772Mon, 20 Sep 2021 00:31:45 +0200https://ask.sagemath.org/question/59101/How show vector or matrix in legend label of plot in latex?https://ask.sagemath.org/question/55304/how-show-vector-or-matrix-in-legend-label-of-plot-in-latex/We can insert latex in legend labels by surrounding the text with '$'. But it doesn't work for a vector (matrix, array), e.g.
\left[\begin{array}{r} 1 \\ 0 \end{array}\right]
Is there any way to display vector in latex in legend label?robSat, 16 Jan 2021 14:32:42 +0100https://ask.sagemath.org/question/55304/Piecewise functions and legend labelhttps://ask.sagemath.org/question/8495/piecewise-functions-and-legend-label/If I plot a piecewise function with a legend label like this:
plot(Piecewise([[(0,1),x],[(1,2),x^2]]),legend_label='f(x)')
I get the legend twice. Is there a way to ensure that it appears only one time, i.e. one legend for the whole function?sagefanSat, 19 Nov 2011 17:37:47 +0100https://ask.sagemath.org/question/8495/No legend when plotting list of pointshttps://ask.sagemath.org/question/7788/no-legend-when-plotting-list-of-points/When I plot points using Sage 4.6 the legend is not drawn.
Running this in notebook:
pts = [point((i, gauss(0,1)),) for i in range(100)]
plot(pts, legend_label='My points').show() #No legend
plot(cos(x), legend_label='cos(x)').show() #This works!
The cos(x) plot works, but not for points, how's that?
Is is a bug, or is it some other library than matplotlib used when plotting points?mandrakeFri, 03 Dec 2010 08:17:32 +0100https://ask.sagemath.org/question/7788/