Can someone help me write the tikz code to generate the following images? I've tried adapting what some other people have done to generate a cylinder, but I want the cylinder with the axes and with the smaller cylinder inside. enter image description here

The code written here is perhaps most useful, Concentric Cylinders with tikz

The code for a basic cylinder is given here 3D bodies in TikZ

I'm new to tikz and have found that upon editing, the lines and dimensions go out of proportion and don't look reasonable any more. I also don't understand how to include lines in these cylinders or how to shade the inside cylinder.

  • 1
    Welcome to TeX.SX! Can you please add the code to your posting that you have obtained by adapting the code of other people? – gernot Mar 25 '17 at 23:21
  • Is the cone code by chance just a copy of texample.net/media/tikz/examples/TEX/3d-cone.tex? – Dr. Manuel Kuehner Mar 25 '17 at 23:40
  • @Dr.ManuelKuehner I have an edited version of this template, but it doesn't look very nice at all. I therefore thought it best to upload the original template. – user412674 Mar 26 '17 at 0:36
  • Please attribute code you use from others. Not only is it common courtesy, it makes it easier for people to help as they can easily find the source for context. Please add the link & author into your question so it is not buried in the comments. – cfr Mar 26 '17 at 0:50
  • I'm not clear how the 3D cone is supposed to feature in the diagram you are trying to draw. It is a long time since I studied geometry, I admit, but the diagrams you show don't seem to include any cones. But if you can draw one cylinder, you should be able to draw 2, one inside the other. The diagrams are not really 3D, so you just need to add some lines and labels, don't you? If you look at the tutorials in the TikZ manual, that should be pretty straightforward. Just think lines plus arrows rather than axes. – cfr Mar 26 '17 at 0:53

It really isn't clear what you've tried or what the problem is. This is almost, therefore, a do-it-for-me and I, therefore, hold that I shouldn't answer it.

As a do-it-for-me, remaining adjustments are left entirely as an exercise for the reader. I will be less sympathetic to requests for fine-tuning and explanation than I would otherwise be.

I answer do-it-for-mes strictly for me. If it happens to be useful, so be it. If not, so be it.

The most useful code you said you found is for a question where the answer does not even use TikZ. I'm not clear whether you were aware of this or not ....

  \draw [fill=gray, fill opacity=.25]
  (180:5mm) coordinate (a)
  -- ++(0,-12.5mm) coordinate (b)
  arc (180:360:5mm and 1.75mm) coordinate (d)
  -- (a -| d) coordinate (c) arc (0:180:5mm and 1.75mm);
  \draw [fill=gray, fill opacity=.25]
  (0,0) coordinate (t) circle (5mm and 1.75mm);
  \draw [densely dashed] (d) arc (0:180:5mm and 1.75mm);
  \draw []
  (180:7.5mm) coordinate (A)
  -- ++(0,-12.5mm) coordinate (B) node [midway, right, inner sep=1pt] {$v$}
  arc (180:360:7.5mm and 2.625mm) coordinate (D)
  -- (A -| D) coordinate (C) arc (0:180:7.5mm and 2.625mm);
  \draw []
  (0,0) coordinate (T) circle (7.5mm and 2.625mm);
  \draw [densely dashed] (D) arc (0:180:7.5mm and 2.625mm);
  \draw [densely dashed ]
  ([yshift=-12.5mm]T) coordinate (B)
  edge [-Latex] node [pos=1, right] {$y$} +(-30:7.5mm)
  edge [-Latex] node [pos=1, left] {$x$} +(-150:7.5mm)
  -- (T) node [midway, right, anchor=west, fill=white, inner sep=.5pt] {$w$} node [anchor=center, circle, draw, solid, inner sep=.5pt, fill=white] {} edge [solid, -Latex] node [right, pos=1] {$z$} ++(0,5mm) ;


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.