What I am trying to do:

I have been Mathematica user for a considerably short while. I have learned some of its functionality using wolfram how-to resources and the documentation. I am having difficulties constructing something similar as shown above.

I was wondering if anyone could give me pointers to resources that would allow me to achieve visuals as presented in the image attached with this question.

My objective is to use a slider to manipulate triangles height and as the slider moves text appears, color changes and values at milestones become visible.

Many thanks in advance!

  • $\begingroup$ I have tried a couple of things. I tried to draw graphics and use ImageResize functionality together within Manipulate function. I have tried to plot it and then use slider to resize it in plot, but that failed as well. I think I know how to use Manipulate and If, however Graphics is something that I have never worked with before. @Kuba $\endgroup$ – user16187 Jun 27 '14 at 10:51
  • $\begingroup$ Something like: Manipulate[ Graphics[{{EdgeForm@Thick, FaceForm[], Polygon[{{0, 0}, {1, 1}, {-1, 1}}], FaceForm[Orange], Polygon[{{0, 0}, {a, a}, {-a, a}}]}}, PlotRange -> {0, 1}], {a, 0, 1}]? $\endgroup$ – Kuba Jun 27 '14 at 10:58
  • $\begingroup$ I have done something similar when trying to use Manipulate with Graphics. Your code looks much neater though. What I don't know how to do is how to dynamically change color and add this text when it reaches some height. I understand that it must be an If statement. I am not sure how to implement it. @Kuba $\endgroup$ – user16187 Jun 27 '14 at 11:04
  • $\begingroup$ Use FaceForm[Hue[a]] instead of FaceForm[Orange]. I mean, you must set the values you need but it is only a matter of writting it with If for example. $\endgroup$ – Kuba Jun 27 '14 at 11:06
  • $\begingroup$ Thank you for your help @Kuba. I really appreciate your time! I just need to get a hang of it. Will try to spend more time on it and see what I can make out of it! I find it rather difficult sometimes to write syntax in Mathematica as I am coming from C++ / Java / Python programming languages. $\endgroup$ – user16187 Jun 27 '14 at 11:15

This is a rough idea you can build up on.

 Graphics[{Text[Text1, {-4, 1}], Text[Text2, {-4, 3}], 
   Text[Text3, {-4, 5}], 
   Text["10^-6", {4, 
     2}], {Line[{{1.5, 2}, {3.4, 2}}]}, {Line[{{2.5, 4}, {3.4, 4}}]}, 
   Text["10^-3", {4, 4}], {Green, 
    Polygon[{{{0, 0}, {-1, 2}, {1, 2}}}]}, {Orange, 
    Polygon[{{-1, 2}, {-2, 4}, {2, 4}, {1, 2}}]}, {Red, 
    Polygon[{{-2, 4}, {-3, 6}, {3, 6}, {2, 4}}]}, {EdgeForm[Thick], 
    Opacity[0], Rectangle[{-5.5, 0}, {5.5, 6.7}]}, {White, 
    Rectangle[{-6, a}, {6.5, 7.5}]}}, PlotRange -> {-1, 7}, 
  ImageSize -> 500], {{a, -1, "Slider"}, -1, 7}, 
 ControlType -> VerticalSlider, ControlPlacement -> Left]
  • $\begingroup$ this is brilliant thank you! $\endgroup$ – user16187 Jun 27 '14 at 14:52

Your Answer

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