Mathematica Asked on March 8, 2021
I’m trying to include the legends inside the frame of the plot like this
Here is my Attempt:
ListPlot[{{2, 5, 2, 8, 6, 8, 3}, {1, 2, 5, 2, 3, 4, 3}},
PlotMarkers -> {"[SixPointedStar]", 15}, Joined -> True,
PlotStyle -> {Orange, Green},
PlotLegends ->
Placed["line1", "line2",
LegendFunction -> (Framed[#, FrameMargins -> 0] &)], Frame -> True]
My references:
Space for the legend is available at the upper left
ListPlot[{
{2, 5, 2, 8, 6, 8, 3},
{1, 2, 5, 2, 3, 4, 3}},
PlotMarkers -> {"✶", 15},
Joined -> True,
PlotStyle -> {Orange, Green},
PlotLegends ->
Placed[
LineLegend[{"line1", "line2"},
LegendFunction -> "Frame"],
{.15, .8}],
Frame -> True]
To locate legend at upper right you must change the PlotRange
ListPlot[{
{2, 5, 2, 8, 6, 8, 3},
{1, 2, 5, 2, 3, 4, 3}},
PlotRange -> {{0, 9}, {0, 9}},
PlotMarkers -> {"✶", 15},
Joined -> True,
PlotStyle -> {Orange, Green},
PlotLegends ->
Placed[
LineLegend[{"line1", "line2"},
LegendFunction -> "Frame"],
{.85, .8}],
Frame -> True]
Correct answer by Bob Hanlon on March 8, 2021
You did not put any location for Placed
ListPlot[{{2, 5, 2, 8, 6, 8, 3}, {1, 2, 5, 2, 3, 4, 3}},
PlotMarkers -> {"[SixPointedStar]", 15}, Joined -> True,
PlotStyle -> {Orange, Green},
PlotLegends -> Placed[LineLegend[{"line1", "line2"},
LegendFunction -> (Framed[#, FrameMargins -> 0] &)], {0.1, 0.5}],
Frame -> True]
Answered by Sumit on March 8, 2021
Often these graphics commands are a bit obscure and one has to try. Is the following approx. what you are looking for?:
ListPlot[{{2, 5, 2, 8, 6, 8, 3}, {1, 2, 5, 2, 3, 4, 3}},
PlotMarkers -> {"[SixPointedStar]", 15}, Joined -> True,
PlotStyle -> {Orange, Green},
PlotLegends ->
Placed[LineLegend[{"line1", "line2"},
LegendFunction -> Framed], {0.85, 0.8}], Frame -> True,
PlotRange -> {{0, 10}, All}]
Answered by Daniel Huber on March 8, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP