Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a plot for which I would like to create an legend that is black and white printer friendly. I have seen Jen's legendmaker but I don't know how to adapt it. I need help in making the legend for the exit region to appear meshed. The graph is incomplete right now and I will add more stuff to it.. like J and V etc etc but for now I want the exit regions and their legends to be black and white printer friendly. What can I do to get a mesh to appear in the legend for the exit region. Thanks

EDIT: Gaps in code fixed.

enter image description here

I1 = 15;
I2 = 8;
f1[x_] := I1;
f2[x_] := I2;
hddd = 20;
h00d = 60;
h00s = 150;
hsss = 180;
    pl1 = Plot[{f1[x]}, {x, 0, 200}, AxesOrigin -> {0, 0}, 
       PlotRange -> {-1, 20}, Epilog -> {
         Inset[
          Grid[{{Text[Style["J", "Garamond", 16]], 
             Text[Style["First Function", "Garamond", 16]]}, {Text[
              Style["V", "Garamond", 16]], 
             Text[Style["Second Function", "Garamond", 16]]}}], {h00s, 
           I1 + 3}],
         Inset[
          Grid[{{Item["", 
              Background -> RGBColor[0.35082, 0.595178, .853742], 
              Frame -> True, FrameStyle -> AbsoluteThickness[1]], 
             Style["Continuation Region", "Garamond", 16]}, {Item["", 
              Background -> RGBColor[1, 1, .4], Frame -> True, 
              FrameStyle -> AbsoluteThickness[1]], 
             Style["Exit Region", "Garamond", 16]}}]], Dashed, 
         Arrowheads[Small], Arrow[{{h00s, I1}, {h00s, 0}}], 
         Arrowheads[Small], Arrow[{{h00d, I1}, {h00d, 0}}], 
         Arrowheads[Small], Arrow[{{hddd, I1}, {hddd, 0}}], 
         Arrowheads[Small], Arrow[{{hsss, I2}, {hsss, 0}}], 
         Inset[Style["Down Boundaries", "Garamond", 
           16], {(hddd + h00d)/2, (I1 + I2)/2}],
         Inset[
          Style["Top Boundaries", "Garamond", 
           16], {(hsss + h00s)/2, (I1 + I2)/2}],
         }, Ticks -> {{{hddd, Text[Style["HDD", "Garamond", 20]]}, {h00d, 
           Text[Style["H0D", "Garamond", 20]]}, {h00s, 
           Text[Style["H0S", "Garamond", 20]]}, {hsss, 
           Text[Style["HSS", "Garamond", 20]]}}, {{I1, 
           Text[Style["High", "Garamond", 20]]}, {I2, 
           Text[Style["Low", "Garamond", 20]]}}}, 
       AxesLabel -> {Text[Style["Variable X", "Garamond", 20]], 
         Text[Style["Variable Y", "Garamond", 20]]}];
    pl2 = Plot[{f2[x]}, {x, 0, 200}, AxesOrigin -> {0, 0}, 
       PlotRange -> {-1, 20}];
    ptd = ListPlot[{{h00d, I2}, {hddd, I1}}, 
       PlotStyle -> {Directive[Red, PointSize[Large]]}, 
       AxesOrigin -> {0, 0}, PlotRange -> {-1, 20}];
    pts = ListPlot[{{h00s, I1}, {hsss, I2}}, 
       PlotStyle -> {Directive[Green, PointSize[Large]]}, 
       AxesOrigin -> {0, 0}, PlotRange -> {-1, 20}];
    r1 = RegionPlot[
       f1[x] > 0, {x, 0, hddd - 1}, {y, I1 - 0.15, I1 + 0.15}, 
       PlotStyle -> RGBColor[1, 1, .4], Mesh -> 2];
    r2 = RegionPlot[
       f1[x] > 0, {x, h00s + 1, 200}, {y, I1 - 0.15, I1 + 0.15}, 
       PlotStyle -> RGBColor[1, 1, .4], Mesh -> 2];
    r3 = RegionPlot[
       f1[x] > 0, {x, 0, h00d - 1}, {y, I2 - 0.15, I2 + 0.15}, 
       PlotStyle -> RGBColor[1, 1, .4], Mesh -> 2];
    r4 = RegionPlot[
       f1[x] > 0, {x, hsss + 1, 200}, {y, I2 - 0.15, I2 + 0.15}, 
       PlotStyle -> RGBColor[1, 1, .4], Mesh -> 2];
    r5 = RegionPlot[
       f1[x] > 0, {x, h00d + 1, hsss - 1}, {y, I2 - 0.1, I2 + 0.1}, 
       PlotStyle -> RGBColor[0.35082, 0.595178, .853742]];
    r6 = RegionPlot[
       f1[x] > 0, {x, hddd + 1, h00s - 1}, {y, I1 - 0.1, I1 + 0.1}, 
       PlotStyle -> RGBColor[0.35082, 0.595178, .853742]];
    Show[pl1, pl2, ptd, pts, r1, r2, r3, r4, r5, r6]
share|improve this question
add comment

1 Answer

up vote 7 down vote accepted

After Amatya's edit

MeshMarker[a_, b_, col_: Lighter@Blue] :=RegionPlot[True, {x, -2, 2}, {y, -2, 2},
 Frame -> False, PlotStyle -> col, Mesh -> {a, b}, ImageSize -> 20]

SwatchLegend[{1, 2}, {"Continuation Region", "ExitRegion"},
LegendMarkerSize -> {{30,30}}, LegendMarkers -> MeshMarker @@@ {{2, 2, Yellow}, {0,0}}]

enter image description here

Before Amatya's edit

There are gaps in Your code so it does not work for me but look at following solutions.

With Mesh

MeshMarker[a_, b_] :=RegionPlot[True, {x, -2, 2}, {y, -2, 2}, Frame -> False, 
Mesh -> {a, b}, ImageSize -> 20];

Show[{
 RegionPlot[x^2 + y^2 < 4, {x, -3, 3}, {y, -3, 3}, Mesh -> {0, 6}, 
 PlotLegends ->      SwatchLegend[{1}, {plot1}, LegendMarkers -> MeshMarker[0, 6], 
  LegendMarkerSize -> 30]],

 RegionPlot[(x - 5)^2 + y^2 < 4, {x, -3, 7}, {y, -3, 3}, Mesh -> {6, 0}, 
 PlotLegends ->     SwatchLegend[{1}, {plot2}, LegendMarkers -> MeshMarker[6, 0], 
  LegendMarkerSize -> 30]]

 }, PlotRange -> All, AspectRatio -> Automatic, ImageSize -> 500
 ]

enter image description here

without mesh

 texture = {
  Rasterize@Graphics[{Thick, Line[{{{0, 0}, {1, 1}}, {{0, 1}, {1, 0}}}]}, 
                     ImageSize -> 30, ImageMargins -> 0],
  Rasterize@Graphics[{Thick, Line[{{{0, 0}, {1, 1}}, {{.5, 0}, {1, .5}}, {{0, .5}, {.5, 1}}}]},
                     ImageSize -> 30, ImageMargins -> 0, PlotRange -> {{0, 1}, {0, 1}}]
 };

Show[{
  RegionPlot[x^2 + y^2 < 4, {x, -3, 3}, {y, -3, 3},
    PlotStyle -> Texture[texture[[1]]],TextureCoordinateScaling -> False,
    PlotLegends -> SwatchLegend[{1}, {"region 1"}, LegendMarkerSize -> {{30, 30}}, 
    LegendMarkers -> texture[[1]]]]
  ,  
  RegionPlot[(x - 5)^2 + y^2 < 4, {x, -3, 7}, {y, -3, 3},
    PlotStyle -> Texture[texture[[2]]], TextureCoordinateScaling -> False,
    PlotLegends -> SwatchLegend[{1}, {"region 2"}, LegendMarkerSize -> {{30, 30}},
    LegendMarkers -> texture[[2]]]]

  }, PlotRange -> All, AspectRatio -> Automatic, ImageSize -> 500
 ]

enter image description here

share|improve this answer
    
I'm sorry for the gaps in the code. I always get careless like this. I'll go over your code now. –  Amatya Jun 5 '13 at 20:43
    
@Amatya Don't worry :) it is not a big deal when question is clear. –  Kuba Jun 5 '13 at 20:45
    
I don't have MMA9 at school but I do have it at home so I will write back in 6-7 hours. Thanks. –  Amatya Jun 5 '13 at 21:03
    
@Amatya No problem, but in case of earlier version MeshMarker can be simply in a Grid like in Your code. –  Kuba Jun 5 '13 at 21:07
    
Sorry I vanished for two weeks. Thanks a lot for your solution! –  Amatya Jun 22 '13 at 14:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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