4

Does anyone know how to replicate this Mathematica plot in tikz? (If possible: I'd like to use "pattern=crosshatched dots" to fill in the shaded region.)

Below is the Mathematica code:

Show[(*Arrows- Top*) Graphics3D[{Black,Arrowheads[0.05],Arrow[Tube[{{0,.5,1},{1.1,.5,1}},.01]],Text[Style["\!\(\*SuperscriptBox[\(\[Epsilon]\), \(+\)]\)",Medium],{0,.5,1.1}]},Boxed->False,Axes->False,Background->None,Lighting->"Neutral",Ticks->None],Graphics3D[{Black,Arrowheads[0.05],Arrow[Tube[{{0,.25,1},{1.1,.25,1}},.01]], Text[Style["\!\(\*SuperscriptBox[\(\[Epsilon]\), \(-\)]\)",Medium],{0,.25,1.1}]}], (*Arrows-Bottom*) Graphics3D[{Black,Arrowheads[0.05],Arrow[Tube[{{0,.25,0},{1.1,.25,0}},.01]], Text[Style["\!\(\*SuperscriptBox[\(\[Epsilon]\), \(-\)]\)",Medium],{1.2,.25,0}]}],Graphics3D[{Black,Arrowheads[0.05],Arrow[Tube[{{0,.5,0},{1.1,.5,0}},.01]],Text[Style["\!\(\*SuperscriptBox[\(\[Epsilon]\), \(+\)]\)",Medium],{1.2,.5,0}]}],(*x-Axes*) Graphics3D[{Black,Arrowheads[0.07],Arrow[Tube[{{0,1,0},{1.3,1,0}},.01]], Text[Style["x",Medium],{1.35,1,0}]}],(*y-Axes*) Graphics3D[{Black,Arrowheads[0.07],Arrow[Tube[{{0,1,0},{0,-.35,0}},.01]],Text[Style["y",Medium],{0,-.5,0}]}], (*y-Axes*) Graphics3D[{Black,Arrowheads[0.07],Arrow[Tube[{{0,1,0},{0,1,1.3}},.01]],Text[Style["n",Medium],{0,1,1.35}]}],(*Surface*) Plot3D[Sqrt[1-x^2],{x,0,1},{y,0,1},Axes->True,AxesLabel->{"x","y","n"},Boxed->False,PlotStyle->Directive[Gray,Opacity[0.5]],Mesh->None,Background->None,Lighting->"Neutral"], (*Epsilon above surface*) RegionPlot3D[Sqrt[1-x^2]<= z,{x,0,1},{y,.25,.5},{z,0,1},PlotStyle->None],RegionPlot3D[ .25<= y<=.5,{x,0,1},{y,.25,.5},{z,-.01,.01},PlotStyle->None]]

Image renderered in *Mathematica*

The red represents the volume to be filled with dots

  • Are you asking for fun or there are any technical issue preventing you from \includegraphics? Please aware that questions looks like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to give a minimal working example (MWE) showing how much you have done yet. you'll stand a greater chance of getting help. – Symbol 1 Mar 17 '15 at 2:46
  • @Symbol1 Technical issue: How to make curved 3D function with patterns and fill region plots with patterns. After many failed attempts I switched to Mathematica to create a MWE to submit to the forum. My 2 cents: From the perspective of a first time user, wouldn’t it make sense to have a template submission form that outlined the particular criterion the forum is looking for? Rather than waste a lot of time and energy on responses such as these? – Barrett Leslie Mar 18 '15 at 20:57
  • 1
    The point is to make the asker to clarify his/her problem. Sometimes there do exists just-for-fun problem but we cannot image that there are 100 such problems per day. Besides, the less you are asking for, the shorter/clearer the code will be. For example, Mathematica draws you beautiful 3D arrows. Do you like such arrows? The cylinder is shaded, is it necessary? As a contrast, you mentioned only pattern=crosshatched dots so Ignasi forget, probably deliberately, the pattern=grid part. – Symbol 1 Mar 19 '15 at 0:31
  • By the way, you may yell that WHO cares about ARROWS, I want OOXXOOX. But Please remember, we just do not konw. TikZ devotes a library to arrow tips so... nothing is impossible and everything is important. – Symbol 1 Mar 19 '15 at 0:38
  • @Symbol1 I apologize for taking so long to respond. my computer broke. Thanks for the response and clarification. The example is for me to visualize concepts in real analysis. I will try to be clearer and more specific w/ questions in the future. – Barrett Leslie Mar 27 '15 at 17:41
12
\documentclass[tikz]{standalone}

\usetikzlibrary{patterns}

\begin{document}
\begin{tikzpicture}
\draw[->] (0,0,0)--++(5,0,0) node[right]{$x$};
\draw[->] (0,0,0)--++(0,5,0) node[above]{$n$};
\draw[->] (0,0,0)--++(0,0,5) node[below left]{$y$};
\draw (0,4,0) arc[start angle=90, end angle=0, radius=4] -- ++(0,0,4.5)
arc[start angle=0, end angle=90, radius=4]--cycle;
\draw[thick, pattern=crosshatch dots] (0,4,1.5) arc[start angle=90, end angle=0, radius=4] -- ++(0,0,1.5)
arc[start angle=0, end angle=90, radius=4]--cycle;
\draw[->, thick] (0,0,1.5)--++(4.5,0,0) node[right]{$\epsilon^+$};
\draw[->, thick] (0,0,3)--++(4.5,0,0) node[right]{$\epsilon^-$};
\draw[->, thick] (0,4,1.5)--++(4.5,0,0) node[right]{$\epsilon^+$};
\draw[->, thick] (0,4,3)--++(4.5,0,0) node[right]{$\epsilon^-$};
\draw[thick, pattern=crosshatch dots] (0,4,1.5)--++(4,0,0)--++(0,0,1.5)--++(-4,0,0)--cycle;
\draw[thick, pattern=crosshatch dots] (4,0,1.5)--++(0,4,0)--++(0,0,1.5)--++(0,-4,0)--cycle;
\draw[thick, pattern=crosshatch dots] (0,0,1.5)--++(4,0,0)--++(0,0,1.5)--++(-4,0,0)--cycle;
\draw[thick, pattern=crosshatch dots] (0,0,1.5)--++(0,4,0)--++(0,0,1.5)--++(0,-4,0)--cycle;
\end{tikzpicture}
\end{document}

enter image description here

Let's try again:

\documentclass[tikz]{standalone}

\usetikzlibrary{patterns}

\begin{document}
\begin{tikzpicture}
%axis
\draw[->] (0,0,0)--++(5,0,0) node[right]{$x$};
\draw[->] (0,0,0)--++(0,5,0) node[above]{$n$};
\draw[->] (0,0,0)--++(0,0,5) node[below left]{$y$};

%curved surface
\draw (0,4,0) arc[start angle=90, end angle=0, radius=4] -- 
    ++(0,0,4.5) arc[start angle=0, end angle=90, radius=4]--cycle;

%internal curved surface        
\draw[thick] (0,4,1.5) arc[start angle=90, end angle=0, radius=4] -- 
           ++(0,0,1.5) arc[start angle=0, end angle=90, radius=4]--cycle;

%Epsilon arrows
\draw[->, thick] (0,0,1.5)--++(4.5,0,0) node[right]{$\epsilon^+$};
\draw[->, thick] (0,0,3)--++(4.5,0,0) node[right]{$\epsilon^-$};
\draw[->, thick] (0,4,1.5)--++(4.5,0,0) node[right]{$\epsilon^+$};
\draw[->, thick] (0,4,3)--++(4.5,0,0) node[right]{$\epsilon^-$};

%vertical epsilon delimited area
\draw[thick] (4,0,1.5)--++(0,4,0)--++(0,0,1.5)--++(0,-4,0)--cycle;

%horizontal hatched rectangle
\draw[thick, pattern=crosshatch dots] (0,0,1.5)--++(4,0,0)--++(0,0,1.5)--++(-4,0,0)--cycle;

%hatched volume
\draw[thick, pattern=crosshatch dots] (0,4,1.5)--++(0,0,1.5) 
     arc[start angle=90, end angle=0, radius=4] --++(0,0,-1.5)--++(0,4,0)--++(-4,0,0);
\end{tikzpicture}
\end{document}

enter image description here

  • Thank you very much! You rock! One question: How do I fill the region between the "top of the curve" and "the epsilon boundaries" w/ the crosshatched pattern? Regardless, thank you for your help it is much appreciated. – Barrett Leslie Mar 18 '15 at 21:05
  • @BarrettLeslie Figure updated. Is what you want? – Ignasi Mar 18 '15 at 23:07
  • Sorry for taking so long to get back. My computer died. Answer: Not exactly.I'm wanting to "fill the volume" w/ dots between the rectangular surface and the top of the curve. i.e. I want to fill the "red region" w/ dots in the image I posted above. – Barrett Leslie Mar 27 '15 at 17:34
  • @BarrettLeslie Updated again. Is it better? – Ignasi Mar 28 '15 at 8:54
  • Yes, that's it exactly. Thank you so much. This will help me w/ other volumes I would like to fill w/ patterns as well! – Barrett Leslie Mar 29 '15 at 21:15

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.