Tag Info

Hot answers tagged

75

Just to get things going... \documentclass[border=0.125cm]{standalone} \usepackage{tikz} \tikzset{gift box/.cd, x/.store in=\gbx, y/.store in=\gby, z/.store in=\gbz, x=0,y=0,z=0 } \tikzdeclarecoordinatesystem{gift box}{% \tikzset{x=(-20:1cm),y=(200:1cm),z=(90:1cm)}% \tikzset{gift box/.cd, #1}% ...


56

Christian was faster, but because I invested the time, here's my take on showing how the bivariate distribution results from the two univariate ones. There are a couple of things in the code that might be useful for you: You can define mathematical functions using declare function={<name>(<argument macros>)=<function>;}, which will help ...


55

What a good question! I'm surprised that no-one's asked this before ... There are two pieces to the puzzle here: getting the end circles right, and deciding where to draw the edges. The first turns out to actually be easy - if you know what to look for in the TikZ manual. The second takes a little bit of maths, but not too much. Let's deal with the ...


43

Here's a Sketch/TikZ approach. Running sketch on this file: def helix { def n_segs 600 sweep [draw=orange] { n_segs, rotate(24*360 / n_segs, (1.5,0,0), [0,0,1]), rotate(1*360/n_segs, (0,0,0), [0,1,0]) } (2.01,0,0) } def torus { def n_segs 60 sweep [draw=none, fill=cyan, fill opacity=0.75] {n_segs, rotate(360/n_segs, (0,0,0), [0,1,0])} ...


40

run with xelatex \documentclass{article} \usepackage{pst-solides3d} \begin{document} \psset{viewpoint=50 20 30 rtp2xyz,Decran=50} \begin{pspicture}[solidmemory](-4,-4)(6,5) \psset{unit=0.5} \psSolid[object=plan,action=draw**,definition=equation,args={[0 0 1 0]}, base=-4 4 -4 4,fillcolor=black!15,fillstyle=solid,name=P0] ...


38

Wasn't sure if "something like that" meant "as near to that as possible". Either way I went with: \documentclass{standalone} \usepackage{tikz} \renewcommand{\familydefault}{\sfdefault} \begin{document} \colorlet{crystal}{blue!75} \def\zangle{-20} \def\xangle{20} \begin{tikzpicture}[x=(\xangle:0.75cm), y=(90:1cm), z=(\zangle:1.5cm), >=stealth, line ...


38

it shows the function x(u,v)=(R1 + (R0 +RL*sin(u))*sin(k*v))*cos(v)-RL*cos(u)*sin(v) y(u,v)=(R1 + (R0 +RL*sin(u))*sin(k*v))*sin(v)+RL*cos(u)*cos(v) z(u,v)=(R0 + RL*sin(u))*cos(k*v) with the parameter setting shown in the example. RL: radius of the coil line; R1: Torus outer; R0: Torus inner radius; k:number of coils run it with xelatex or ...


38

Tabulated data can be plotted in different planes quite easily by using \addplot3 table [y expr=<value>, z=<name of column in table>] {<file name or table macro>};. You can use \pgfplotsinvokeforeach{<list expression>}{...} to repeat the plot commands. Here's an example of how to plot your dummy data: \documentclass{article} ...


33

What you need is to sample a bivariate function and to choose a proper plot type. Typical choices are mesh, surface, or contour plots. The most common is a surface plot, I think. In any case, TikZ does not support bivariate functions - but you can use pgfplots which is build on top of it and provides simple integration into tikz. I should note that I am ...


33

To be honest, I don't understand the spiral code to well, at lest not why switching the roles of x and z leads to strange results. So I would recommend using Tikz's plot operation: Code \documentclass[a4paper,11pt]{article} \usepackage{kerkis} \usepackage{tikz} \usetikzlibrary{% calc,% fadings,% shadings% } ...


32

It was suggested in chat http://chat.stackexchange.com/transcript/message/9482087#9482087 That picture mode would be the ideal tool for the job here: \documentclass{article} \begin{document} \begin{picture}(200,100) \put(30,40){\line(1,0){150}} \put(30,40){\line(0,1){60}} \put(30,100){\line(1,0){20}} \put(50,100){\line(1,-4){10}} ...


30

Here you go with the sphere and cone and truncated cone: \documentclass[parskip]{scrartcl} \usepackage[margin=15mm]{geometry} \usepackage{tikz} \usetikzlibrary{3d,calc} \begin{document} \begin{tikzpicture} \draw (-1,0) arc (180:360:1cm and 0.5cm); \draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm); \draw (0,1) arc (90:270:0.5cm and 1cm); ...


27

Another solution. The placement of the nodes depends of the coordinates system. With this method, you have nothing todo to get a fine placement for the texts. The projection is "include" in the option because you specify the plane that you want to use. Remarks : If you don't want to scale the text and generally it's better to avoid this modification but ...


25

TikZ also has an xyz-coordinate system that is quite useful here. There's a nice answer making use of this feature: Table, i.e. the piece of furniture on which one eats, in Tikz Here's a way of drawing your octahedron. To rotate it, play around with the x, y and z options of the tikzpicture: \documentclass{article} \usepackage{tikz} \begin{document} ...


24

The code is a draft version. I need to remove xkeyval and to use pgfkeys. I need to add some options : \documentclass[11pt]{scrartcl} \PassOptionsToPackage{dvipsnames,svgnames}{xcolor} \usepackage{xkeyval,tkz-base} \usetikzlibrary{arrows,calc} \makeatletter% % \pgfkeys{ % /tkzcone/.cd, % } \define@cmdkey[TKZ]{ell}{color}{} ...


24

To give a correct answer, we need to define cross product and vector product (this work is done with metapost in cahier gutemberg 48 but it's in french) I don't have enough time to define all these macros but it's possible to find a way to draw the arc. First we know that the arc PQ (blue) is in the plane OPQ and is a part of a circle of center O and radius ...


23

Since you want to use this for UML diagrams, I think a custom node shape is the right way to go here. It's a lot more overhead and requires getting under PGF's hood/bonnet, but the payoff is that it the drawing code looks just like any other TikZ code: \documentclass{article} \usepackage{tikz} \makeatletter \pgfkeys{/pgf/.cd, parallelepiped offset ...


23

Edit: With some thanks to Toscho, I've updated this answer to use the cm option. This manually applies the coordinate system to the canvas for the node text. You can use xslant. In this case the slant must be set to the tangent of 90-Z where Z is the angle of the "z-vector". In the example below, I explicitly state the x, y, and z vectors at the start of ...


23

EDIT: A new version is added below which uses a single decoration to do most of the work, and draw the dashed lines for the cone behind the screen automatically. I'm never going to claim this is (a) straightforward (b) robust, or (c) elegant, but it might show one way of getting close to the requirements. It only works with objects made up of straight ...


21

Definitely not perfect, and it mostly could/should be parameterised (and the `frontwrapping' layer is arguably unecessary): \documentclass{article} \usepackage{tikz} \begin{document} \pgfdeclarelayer{backwrapping} \pgfdeclarelayer{frontwrapping} \pgfsetlayers{backwrapping,main,frontwrapping} \tikzset{ wrapping/.style={ draw=black!60, ...


20

Well, no prizes for speed (not just because there is some duplication of calculations: TikZ is slow for this kind of stuff), but this shows one way of doing it. I expect asymptote/PSTricks could do it quicker, but I don't see any other way of doing it in TikZ. The maths is straightforward "back-of-the-envelope" trigonometry (in this case literally). The ...


20

I'm sure that there are better ways, but here's one: \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} \pgfmathsetmacro{\cubex}{2} \pgfmathsetmacro{\cubey}{1} \pgfmathsetmacro{\cubez}{1} \draw[red,fill=yellow] (0,0,0) -- ++(-\cubex,0,0) -- ++(0,-\cubey,0) -- ++(\cubex,0,0) -- cycle; \draw[red,fill=yellow] (0,0,0) -- ...


20

Version 1 You define xand y to get correct a and k. It's not the unique way and it's also possible to reduce the code with a macro. \documentclass[]{scrartcl} \usepackage{tikz} \usetikzlibrary{3d} \begin{document} \begin{tikzpicture}[x = {(-0.65cm,-0.45cm)}, y = {(0.65cm,-0.45cm)}, z = {(0cm,0.8cm)}, ...


20

It is possible, but it does not neccessarily help understanding. The first is a rotation with constant angular velocity about the z-axis, which you probably get from the picture. But it gets quite incomprehendable from there: I wouldn't know what the second one is. So I started experimenting. The next two explore the possibility to draw surfaces connecting ...


20

Further explanations will follow, for now so much: put your sketch in a node recreate the lines using draw commands (I used to[in=,out=,looseness=]) remove the sketch It's far from perfect, somee labels are missing. You can increase the quality ba adding more intermediate points. (Final) Code \documentclass[parskip]{scrartcl} ...


19

TikZ cannot do this with builtin methods. pgfplots can do it - in your case with \addplot3[surf, mesh/ordering=x varies] table {myfile.dat}; . It supports custom colormaps, color bars, draws an appropriate axis, chooses suitable scales, ticks, and ticklabels etc. See http://pgfplots.sourceforge.net/pgfplots.pdf for details and examples. By default, ...


19

Two examples of what you can draw with the 3d library. The first on has been modified because something was wrong with shade colour. \documentclass[]{article} \usepackage{tikz} \usetikzlibrary{3d} \usepackage[active,tightpage]{preview} \PreviewEnvironment{tikzpicture} \setlength\PreviewBorder{5pt}% \begin{document} \begin{tikzpicture} ...


19

I know that this is not what the question was about, but it is an attempt of a 3D cube, with perspective. I don't know how to do it with grids like Stefan's example, but with coordinate calculations and intersections, one can do something like this. It is not mathematically correct, but I think it looks pretty good. \documentclass[]{article} ...


19

You could start with something like this: http://github.com/lahvak/TeX-stuff/blob/master/plane.tex (I tried to include the code here, but it was too large.) It will produce a picture like this: You can then edit the code, clean it up, shorten it, etc. Edit: I took the original .png image, deleted some irrelevant parts, and use potrace to get a ...


19

There is one of my "hackish" solutions, not to be taken too seriously. I'll show first the result, then the high-level code, then the ugly macro which draws one cylinder and its wrapping, and finally the explanations about how I did it all. 1. The result 2. High level tikzpicture It contains a loop in which a strand is drawn from previous nucleosome to ...



Only top voted, non community-wiki answers of a minimum length are eligible