I am having trouble making the dot marker for Cosec(x) larger. The plot points should be size 1% but the legend marker is super tiny and I don't know how to make it larger.
ClearAll[x]
g1 = Plot[Sin[x], {x, -3 Pi, 3 Pi}, PlotStyle -> Directive[Black, Thick, Dashed], PlotLegends -> {"Sin(x)"}, PlotRange -> {-3, 3}, Ticks -> {{-3 Pi, -2 Pi, -Pi, 0, Pi, 2 Pi, 3 Pi}, {-3, -2, -1, 0, 1, 2, 3}}];
ClearAll[x]; x = Table[{x, Csc[x]}, {x, -3 Pi, 3 Pi, 0.1}];
g2 = ListPlot[x, PlotStyle -> Directive[Red, PointSize -> 0.01], PlotLegends -> {"Cosec(x)"}];
Show[g1, g2, AxesLabel -> {"x", "y"}]
For clarity, here is the assignment question:
"Graded exercise 1: On the same graph, plot two functions, sin(x) and cosec(x) on the interval [-3[Pi],3[Pi]]. The function sin(x) should be plotted as a thick dashed black line and cosec(x) should be plotted as red points, with horizontal distance between points of 0.1; point size 1% of the total size. Label the horizontal axis "x" and the vertical axis "y". Provide an appropriate legend and choose an appropriate vertical range. [20%]"
PlotLegends
:legend = Grid[{{Graphics[{Red, Disk[{0, 0}, 0.1]}, ImageSize -> 5], "Cosec(x)"}}]; g2 = ListPlot[x, PlotStyle -> Directive[Red, PointSize -> 0.01], PlotLegends -> legend];
$\endgroup$PlotLegends -> SwatchLegend[{"Cosec(x)"}, LegendMarkerSize -> 20, LegendMarkers -> "Bubble"]
instead ofPlotLegends -> {"Cosec(x)"}
? $\endgroup$LegendMarkerSize
. It seems from the two previous comments that this is may not be the case. Instead on has to either create aGraphics
object oneself or useSwatchLegend
. Both routes are more complicated than expected and hard to find via the help search function. (I had this problem under time pressure once and I couldn't sort it in Mathematica.) $\endgroup$"Bubble"
option? It's not in the documentation. $\endgroup$ChartElementData[SwatchLegend]
. $\endgroup$