Skip to main content
Tweeted twitter.com/StackMma/status/1249895423164264448
Became Hot Network Question
edited body
Source Link
zipirovich
  • 300
  • 3
  • 9

How to modify the legends produced by "Expressions" in the PlotLegendaPlotLegends option

I'm creating a fairly simple plot with a bunch of similar graphs in it. It looks something like this (but with more than two functions):

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> "Expressions"]

And it produces the following plot, as expected:

enter image description here

But I want each equation in the legend to say "$y=\ldots$", i.e. I want to produce the following:

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> {"y=x+2", "y=x-2"}]

enter image description here

As you can see, I manually typed all equations into PlotlegendsPlotLegends. But I don't want to do that, because in my actual application I have more than two functions on the same graph. Is it possible to still use "Expressions" in PlotLegends, but to somehow modify all of them at once, because I want to add "y=" to all of them?

How to modify the legends produced by "Expressions" in the PlotLegenda option

I'm creating a fairly simple plot with a bunch of similar graphs in it. It looks something like this (but with more than two functions):

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> "Expressions"]

And it produces the following plot, as expected:

enter image description here

But I want each equation in the legend to say "$y=\ldots$", i.e. I want to produce the following:

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> {"y=x+2", "y=x-2"}]

enter image description here

As you can see, I manually typed all equations into Plotlegends. But I don't want to do that, because in my actual application I have more than two functions on the same graph. Is it possible to still use "Expressions" in PlotLegends, but to somehow modify all of them at once, because I want to add "y=" to all of them?

How to modify the legends produced by "Expressions" in the PlotLegends option

I'm creating a fairly simple plot with a bunch of similar graphs in it. It looks something like this (but with more than two functions):

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> "Expressions"]

And it produces the following plot, as expected:

enter image description here

But I want each equation in the legend to say "$y=\ldots$", i.e. I want to produce the following:

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> {"y=x+2", "y=x-2"}]

enter image description here

As you can see, I manually typed all equations into PlotLegends. But I don't want to do that, because in my actual application I have more than two functions on the same graph. Is it possible to still use "Expressions" in PlotLegends, but to somehow modify all of them at once, because I want to add "y=" to all of them?

Source Link
zipirovich
  • 300
  • 3
  • 9

How to modify the legends produced by "Expressions" in the PlotLegenda option

I'm creating a fairly simple plot with a bunch of similar graphs in it. It looks something like this (but with more than two functions):

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> "Expressions"]

And it produces the following plot, as expected:

enter image description here

But I want each equation in the legend to say "$y=\ldots$", i.e. I want to produce the following:

Plot[{x + 2, x - 2}, {x, -3, 3}, PlotRange -> {{-3.1, 3.1}, {-4, 4}},
    PlotLegends -> {"y=x+2", "y=x-2"}]

enter image description here

As you can see, I manually typed all equations into Plotlegends. But I don't want to do that, because in my actual application I have more than two functions on the same graph. Is it possible to still use "Expressions" in PlotLegends, but to somehow modify all of them at once, because I want to add "y=" to all of them?