I have a diagram I'd like to reproduce in TikZ:

enter image description here

Picture a can (cylinder of radius r and height L) that has liquid in it. In each diagram, the can is tilted so that the surface of the liquid just touches where the top meets the sides. In the first diagram, the liquid covers the entire bottom, while in the second, only half.

Edit: Yes, I could do this myself given the time, but I'd like to see how others would handle the 3D aspect. Is there a better way to draw a projected circle than to draw an ellipse? [There you go @Andrew.]

The optimal code would use styles and named coordinates so that one could alter the diagram by changing only a few parameters.

  • 14
    draw-this-for-me-im-lazy :-) Oct 12, 2011 at 13:31
  • 4
    @MartinScharrer: Should be draw-this-for-me-im-busy. Possible additional tags: crowdsourcing, procrastination. :-) Oct 12, 2011 at 13:38
  • Could close as "not a real question" given the distinct lack of question marks. Oct 12, 2011 at 14:02
  • 2
    Another possible tag: rep-cow. A question you can answer to "milk" a lot of rep points. Oct 12, 2011 at 14:09
  • 1
    @MatthewLeingang: Tell you what, if you turn your question into a proper question then I'll turn my answer into a proper answer (assuming that no-one gets in first). Oct 12, 2011 at 20:49

2 Answers 2


Do you want something a bit like this?

cylinders with liquid

If so, I'm afraid I don't know how to do that.

(Added in edit after question was closed. The above was produced using TikZ, contrary to my comment below. However, the code is messy and not elegant - it was a quick hack to make the joke. I've sent it privately to Matthew but I am not going to post it here. There are some interesting aspects in doing a drawing such as this one, so if anyone is interested in producing diagrams like this one then I encourage them to think carefully about which bits they could do and which would be hard, and then ask a focussed question specifically about the hard bits.)

  • 4
    I guess Matthew wants it in grey and it should have a look as photo copied. (Or it's just my dirty display.)
    – topskip
    Oct 12, 2011 at 15:32
  • 3
    No +15 for you until I see your code. :-) Oct 12, 2011 at 15:46
  • 1
    Wow, that's awesome Ansdrew. Can't recall ever laughing so much from something on this site. Now I know how to quickly post solutions here and build up a reputation. :-) Oct 12, 2011 at 16:34
  • 3
    Code? What code? I don't have any code for that. I just took your diagram, added some colour using GIMP, and reposted it. Now, if you'd asked a sensible question like "How do you get proper 3D-looking circles in TikZ?" then maybe I could have provided some code to answer that. Oct 12, 2011 at 18:32
  • 2
    I'm also waiting for the codes Oct 12, 2011 at 19:45

This example could be a good start for you, but it uses pst-solides3d (I found here...) and maybe you may get something similar with tikz.

  \psset{viewpoint=20 10 10,Decran=40,lightsrc=20 10 5,solidmemory}
  \defFunction{cone}(u,v){u v Cos mul}{u v Sin mul}{u}
  \psSolid[object=surfaceparametree,base=-2 2 0 2 pi mul,
     inhue=0.8 0.2,hue=0.8 0.2,
     ngrid=25 40,fillcolor=cyan!50,
     intersectionplan={[1 0 0 -1]},
    args={[1 0 0 0]},
%    args={[1 0 0 -1]},
    base=-2 2 -2.5 2.5,ngrid=30 30,action=none,name=Plane]
  \psSolid[object=fusion,base=XYZ Plane_s]

enter image description here


Not the answer you're looking for? Browse other questions tagged .