How do I label different curves in Mathematica?

前端 未结 3 1820
忘掉有多难
忘掉有多难 2020-12-02 09:10

How can I label each of these lines separately :

Plot[{{5 + 2 x}, {6 + x}}, {x, 0, 10}]

3条回答
  •  温柔的废话
    2020-12-02 09:32

    You can insert legends in your plot by loading the PlotLegends package

    <{"5+2x","6+x"},LegendShadow->None,
        LegendPosition->{0.3,-0.5},LegendSpacing->-0,LegendSize->0.5]
    

    enter image description here


    However, let me also note my dislike of this package, primarily because it's extremely counterintuitive, laden with too many options and does not provide a clean experience right out of the box like most of Mathematica's functions. You will have some fiddling around to do with the options to get what you want. However, in plots and charts where you do want a legend, this can be handy. Also see the comments to this answer and this question.

提交回复
热议问题