3
$\begingroup$

Dear users I am a new member here and I would like to ask a question about PlotLegends.

I have multiple curves and want to make their legends bit more visible. Here is a sample code:

Plot[{Sin[h], Cos[h], Tan[h]}, {h, 5, 10}, 
  PlotStyle -> {{GrayLevel[0], Dashing[None],Thickness[0.005]}, 
                {GrayLevel[0], Dashing[0.01],Thickness[0.005]}, 
                {GrayLevel[0], Dashing[0.02],Thickness[0.005]}, 
                {GrayLevel[0], Dashing[0.03],Thickness[0.005]}}, 
  Axes -> False, Frame -> True,
  PlotLegends -> Placed[{"sin", "cos", "tan"}, Top]]

I assume that the problem comes from the Dashing[] specifications making the legends line not visible enough.I may have up to 7 curves so i need and alternative to Dashing[] or any other way to increase lengths of legends and make them more visible.

$\endgroup$
9
  • 1
    $\begingroup$ Welcome to MMA.SE! What do you mean by "a bit more visible"? If you can post some code you already tried, then all the better. Otherwise it might be difficult to answer your question properly. $\endgroup$
    – Yves Klett
    Commented Aug 13, 2013 at 9:17
  • $\begingroup$ You can try here if you are using PlotLegend on a version of Mathematica < 9. $\endgroup$
    – Öskå
    Commented Aug 13, 2013 at 9:32
  • $\begingroup$ i applied standard PlotLegend; and i was sure every body would know that the legends created by it are too short and dashing is not visible at all in most of the cases. i want to know if i could increase the length of these legends. i have read something about legendmaker in this forum but i couldn't figure it our well. i cannot customize it for my problem so i will be really thankful if someone can guide me in that. $\endgroup$
    – naveed
    Commented Aug 13, 2013 at 9:32
  • 1
    $\begingroup$ As Yvers Klett said you should edit your question and add the PlotLegends that you used. $\endgroup$
    – Öskå
    Commented Aug 13, 2013 at 9:48
  • 1
    $\begingroup$ @yves I'm glad someone is still remembering to welcome new users! $\endgroup$
    – cormullion
    Commented Aug 13, 2013 at 10:06

1 Answer 1

3
$\begingroup$

The scaling of the Dashing gets messed up a little, therefore I suggest the following:

Plot[{Sin[h], Cos[h], Tan[h]}, {h, 5, 10}, 
      PlotStyle -> {
        {GrayLevel[0], Dashing[None], Thickness[0.005]}, 
        {GrayLevel[0], Dashing[Tiny], Thickness[0.005]}, 
        {GrayLevel[0], Dashing[Small],Thickness[0.005]}, 
        {GrayLevel[0], Dashing[Medium],Thickness[0.005]}}, 
      Axes -> False, Frame -> True, 
      PlotLegends -> Placed[
                      LineLegend[
                        Automatic, {"sin", "cos", "tan"}, 
                        LegendMarkerSize -> {{45, 15}}],
                      Top]
     ]

LegendMarkerSize increases the Length of the Legend lines and {Tiny,Small,Medium} instead of numeric arguments transfer properly to the Legend.

enter image description here

$\endgroup$
3
  • $\begingroup$ Dear i think it solves my problem, but can you please tell me full list of these styles,i mean Tiny,Small,Medium then what? big or larg? please if you can tell me 7 of these my problem will be solves $\endgroup$
    – naveed
    Commented Aug 13, 2013 at 11:16
  • $\begingroup$ Here i had 4 dashing styles; I need 3 more please let me know about them as well. $\endgroup$
    – naveed
    Commented Aug 13, 2013 at 11:26
  • $\begingroup$ Have a look at the documentation of Dashing here reference.wolfram.com/mathematica/ref/Dashing.html. You only get four with Tiny, Small, Medium, Large (see Details section of page), but you can just specify r manually or a series of these (for different dash size patterns). $\endgroup$
    – Jonie
    Commented Aug 13, 2013 at 11:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.