2
$\begingroup$

I have three questions about the following code:

Plot[{1/2 - 3/2 \[Lambda], Min[1/2 - 3/2 \[Lambda], Sqrt[\[Lambda]]]}, {\[Lambda], 0, 1/9}, AxesLabel -> {\[Lambda], \[Gamma]}, PlotStyle -> Black, Filling -> {1 -> {{2}, White}, 2 -> {Axis, Red}},  AxesStyle -> {Directive[Black], Directive[Blue]}, Epilog -> {Text[Style["FULLY ATTRACTIVE", 36], Scaled[{0.6, 0.25}]], Red}]

Mathematica graphics

  1. How can I plot a series of given points on the plot obtained by code shown? For example suppose I have the following series of points:

    {{0.000297159,0.029389}, {0.00114653,0.0566384}, {0.00249252,0.082004},{0.00428816,0.105703} (* etc. *)}
    
  2. Is there a more effective way to write the text "FULLY ATTRACTIVE" in the red region of the plot?

  3. How can I change the axes dimension?

Thanks.

$\endgroup$
7
$\begingroup$

First thing let's plot the points

points = {{0.000297159, 0.029389}, {0.00114653, 
    0.0566384}, {0.00249252, 0.082004}, {0.00428816, 0.105703}(*etc.*)};

For that you can keep using Epilog while paying attention to make all its content a valid Graphics element:

plot = Plot[{1/2 - 3/2 \[Lambda], 
  Min[1/2 - 3/2 \[Lambda], Sqrt[\[Lambda]]]}, {\[Lambda], 0, 1/9}, 
 AxesLabel -> {\[Lambda], \[Gamma]}, PlotStyle -> Black, 
 Filling -> {1 -> {{2}, White}, 2 -> {Axis, Red}}, 
 AxesStyle -> {Directive[Black], Directive[Blue]}, 
 Epilog -> {Orange, PointSize[.02], Point[points]}]

The result is

plot_with_points

Your text can be fit into the red shape by making it a little smaller, but let's assume you don't want to manually find the good fit. A possibility is to use WordCloud to find a good layout for you (with the caveat that it's not preserving the ordering of the words, so this method is not valid in general for multi-words labels).

We need to define the appropriate mask:

mask = Binarize[
  Plot[{1/2 - 3/2 \[Lambda], 
    Min[1/2 - 3/2 \[Lambda], Sqrt[\[Lambda]]]}, {\[Lambda], 0, 1/9}, 
   AxesLabel -> {\[Lambda], \[Gamma]}, PlotStyle -> Black, 
   TicksStyle -> Transparent, AxesStyle -> Black, 
   Filling -> {2 -> {Axis, White}}, Background -> Black]]

text_mask

Now we can compute the layout (Erosion is used to leave a little margin)

text = WordCloud["FULLY ATTRACTIVE", Erosion[mask, 5], 
  ColorFunction -> Black];

and use Overlay to compose it with the original plot without worrying too much about the coordinates

Overlay[{plot, text}]

enter image description here

$\endgroup$
2
  • $\begingroup$ Thank you Batracos! $\endgroup$
    – Michaels
    Jul 13 '17 at 18:48
  • 2
    $\begingroup$ +1. Nice application of WordCloud! $\endgroup$ Sep 12 '17 at 6:37
0
$\begingroup$
Plot[{1/2 - 3/2 \[Lambda], 
  Min[1/2 - 3/2 \[Lambda], Sqrt[\[Lambda]]]}, {\[Lambda], 0, 1/9},
 AspectRatio -> 1,
 AxesLabel -> {\[Lambda], \[Gamma]},
 PlotStyle -> Black,
 Filling -> {1 -> {{2}, White}, 2 -> {Axis, Red}},
 AxesStyle -> {Directive[Black], Directive[Blue]},
 Epilog ->
  {Text[Style["FULLY ATTRACTIVE", 26], Scaled[{0.6, 0.25}]],
   PointSize@0.02, Red, Point[{{0.00114653, 0.0566384},
     {0.00114653, 0.0566384}, {0.00249252, 0.082004}, {0.00428816, 0.105703}}]}

enter image description here

(1) Some points added

(2) Change axes-dimension with AspectRatio

$\endgroup$
3
  • $\begingroup$ Thank you eldo! $\endgroup$
    – Michaels
    Jul 13 '17 at 18:47
  • $\begingroup$ You're welcome, hope this helps a little bit $\endgroup$
    – eldo
    Jul 13 '17 at 18:58
  • $\begingroup$ How can I give a different shapes (say Triangles, X's, Squares ecc...) to different series of points plotted? Thank you. $\endgroup$
    – Michaels
    Jul 19 '17 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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