I am looking for a help with Latex. I'm new here so unfortunately I'm not allowed to post pictures yet.
I have a tikzpicture plot with labeled axes (x and y). Now I would like to add an arrow below the x-axis to indicate the direction of the subsequential treatments. In addition I would like to have an arrow left of the y-axis label pointing upwards. This arrow should have a second label saying "relative increase in Fe".
\begin{figure}[htbp]
\centering
\begin{tikzpicture}[scale=1]
\begin{axis}[
%legend style={at={(1.05,0.05)}, %gibt Ort für Legende an
%anchor=south west},
%axis x line=bottom, % erzeugt x-Achse mit Pfeil
%axis y line=left, %
width=15.5cm,
height=10cm,
%scaled ticks=false,
%ymin=0,
xmin=-0.5,
xmax=5,
ymin=0,
ymax=5,
xtick={0,1,2,3,4},
xticklabels={Fe2O3,1,2,3,4},
bar width=50pt,
%ytick={},
%yticklabels={},
%use un%%ts,
%x unit=-,
%x unit prefix=,
%y unit=\frac{m}{s},
%y unit prefix=,
xlabel=Subsequential Treatments over Time ,
ylabel=Auger Peak to Peak Height Ratio Fe:O,
x tick label style= {rotate=90,anchor=east},
ybar stacked]
\addplot [draw=white, very thin]
coordinates {(0,1) (1,1) (2,3) (3,2) (4,1.5)};
\addplot [draw= blue, fill=blue]
coordinates {(0,1) (1,1) (2,3) (3,2) (4,1.5)};
%\node at (100,1) [orange!50!yellow]{\small{ZnO-h}};
\end{axis}
\end{tikzpicture}
\caption[Auger Spectrum of HOPG]{Auger Peak to Peak Height Ratios of Fe:O at an primary electron beam of \unit{2.0}{keV}.}
\label{Auger_ratio_histogram_}
\end{figure}
The code below illustrates two techniques for placing such arrows. The starting point of both is to add name=MyAxis to the axis options, which allows you to refer to the anchor points of the axis as with a normal node. A pgfplots axis also has anchors such as outer north east, which lies outside the axis descriptions, while north east lies on the corner of the axes.
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
name=MyAxis,
%legend style={at={(1.05,0.05)}, %gibt Ort für Legende an
%anchor=south west},
%axis x line=bottom, % erzeugt x-Achse mit Pfeil
%axis y line=left, %
width=15.5cm,
height=10cm,
%scaled ticks=false,
%ymin=0,
xmin=-0.5,
xmax=5,
ymin=0,
ymax=5,
xtick={0,1,2,3,4},
xticklabels={Fe2O3,1,2,3,4},
bar width=50pt,
%ytick={},
%yticklabels={},
%use un%%ts,
%x unit=-,
%x unit prefix=,
%y unit=\frac{m}{s},
%y unit prefix=,
xlabel=Subsequential Treatments over Time ,
ylabel=Auger Peak to Peak Height Ratio Fe:O,
x tick label style= {rotate=90,anchor=east},
ybar stacked]
\addplot [draw=white, very thin]
coordinates {(0,1) (1,1) (2,3) (3,2) (4,1.5)};
\addplot [draw= blue, fill=blue]
coordinates {(0,1) (1,1) (2,3) (3,2) (4,1.5)};
%\node at (100,1) [orange!50!yellow]{\small{ZnO-h}};
\end{axis}
\draw [-latex] ([yshift=-2ex]MyAxis.outer south west) --node[below]{Direction of subsequential treatments} ([yshift=-2ex]MyAxis.outer south east);
\draw [-latex] (MyAxis.outer south west) ++(-2ex,0) coordinate(start) --node[sloped,above] {relative increase in Fe} (start |- MyAxis.outer north west);
\end{tikzpicture}
\end{document}
Related
When using Julia / plots heatmap polar plot, the default zero position for the theta axis is or the right ("East") with the angle increasing counter-clockwise, as shown in this example.
How do you reverse the axis and set the zero position for a polar plot in Matplotlib?
I want to have the zero in the "North" position and have a clockwise orientation. How can I do this ?
Thanks
For some reason, two very simple Bar graphs look very different after compiling in tex. More precisely, on the right graph there is a distance from the columns to the lower border of the square. In the left graph, the columns are adjacent to the lower border of the square. I would like to change the left figure, to have the distance between the bottom of the square and the blue columns on the left chart, as it is implemented on the right. Do you know how to change the code of the left chart?
A picture of the graphs
\begin{figure}[H]
\begin{minipage}[h]{0.49\linewidth}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.75,-1)},
anchor=north,legend columns=-1},
symbolic x coords={1,2,3,4,5,6},
xtick=data,
nodes near coords,
nodes near coords align={vertical}
]
\addplot coordinates {(1, 179) (2, 122) (3, 79) (4, 59) (5, 49) (6, 205) };
\end{axis}
\end{tikzpicture}
\end{minipage}
\hfill
\begin{minipage}[h]{0.49\linewidth}
\begin{tikzpicture}
\begin{axis}[
ybar,
enlargelimits=0.15,
legend style={at={(0.75,-1)},
anchor=north,legend columns=-1},
symbolic x coords={1,2,3,4,5,6},
xtick=data,
nodes near coords,
nodes near coords align={vertical}
]
\addplot coordinates {(1, 125) (2, 106) (3, 27) (4, 49) (5, 12) (6, 5) };
\end{axis}
\end{tikzpicture}
\end{minipage}
\end{figure}
I was having trouble plotting a horizontal line
...
set arrow 2 from graph 0, y(x) to x, y(x) nohead
...
For clarity, assume that x = 1 => y = 3 So as far as I understood, that should have generated a line from (0,3) to (1, 3). However, the y coordinate of the first point (0,3) turned out to appear somewhere outside the plot. But if I use (according to a post here)
set arrow 2 from graph 0, first y(x) to x, y(x) nohead
then it yields the output I wanted.
Can someone explain to me the magic above using first?
It is worth reading help coordinates to learn about the different coordinate systems. In short, the first coordinate system is that defined by the current ranges of the x and y axes: the bottom left corner of the graph has coordinates (xmin,ymin), and the top right corner has coordinates (xmax, ymax). In the graph coordinate system the bottom left corner is always (0,0) and the top right corner is always (1,1), independent of the ranges of the two axes.
Here is a brief example:
set xrange [-4:4]
set yrange [-3:3]
set grid
set arrow 1 from first 0,0 to first 1,1 ls 1 lw 3
set arrow 2 from graph 0,0 to graph 1,1 ls 2 lw 3
plot 1/0 ti ""
The purple vector is arrow 1, which goes from (0,0) to (1,1) in the first coordinate system. The second vector is arrow 2, which goes from (0,0) to (1,1) in the graph coordinate system.
The default rules for which coordinate system will be used are
If the coordinate system for x is not specified, first is used. If
the system for y is not specified, the one used for x is adopted.
and for the special case of set arrow,
A coordinate system specifier does not carry over from the first endpoint description [to] the second.
It sounds like you want to use the first coordinate system, so you shouldn't have to do anything:
set arrow from 0, y(x) to x, y(x)
When you use
set arrow from graph 0, y(x) to x, y(x)
you use the graph coordinate system for the starting point, and the first coordinate system for the end point.
When you use
set arrow from graph 0, first y(x) to x, y(x)
you use the graph coordinate system for the starting point's x coordinate, and the first coordinate system for the remaining coordinates. If range of the x axis starts at zero, this would be the same as using the first coordinate system for everything.
Is it possible to "get" the x/y (or other) axis plot range values?
The reason I am trying to do this is that I want to plot a vertical line on my graph at the position of an asymptotic point... Perhaps there is an alternative or better way of doing this than drawing an arrow (with no head) on the graph?
Thanks to #Christoph (again) I have been able to do the following:
#Plot asymptote
set arrow from b,graph 0 to b,graph 1 lt 2 lw 2 lc rgb "green" nohead
This code does the following:
draws an arrow
start position: x=variable b, y=graph 0 (minimum of graph [y] axis)
end position: x=variable b, y=graph 1 (maximum of graph [y] axis)
line type 2 (may require set termoption dashed to enable dashed lines, consult documentation)
line width 2
line color green
no arrow head (a line)
I am looking to plot a graph which has a semi circle from -3 to 3 on the x axis and 0 to 3 on the y axis. I would like for the semi circle and its interior to be untouched but the rest of the graph be filled with grid lines (with a point with increments of .06 for x and y values). I have been able to plot a graph with the semi circle and the grid lines but can't seem to figure out how to clear the semi circle of grid lines.
Any help would be greatly appreciated!
Here's what I have so far, with f[x] being the function for the semicircle and the xPoints and yPoints being the x and y coordinates.
Plot[f[x], {x, -3, 3},
GridLines -> {{xPoints},{yPoints}}]
try working with RegionPlot
RegionPlot[ x^2+y^2 < 9 , {x,-3,3 }, {y,0,3} , Mesh->10 , AspectRatio->Automatic,
MeshShading->{{None,None},{None,None}} ]
( Just switch the inequality to get the grid outside the curve )