TeX - LaTeX Asked on February 6, 2021
I’m trying to generate a log plot of some data using pgfplots
. I’ve mostly got it looking how I want, but I’d like the plot to show the data continuing down toward the origin rather than stopping at the x=0.05
datapoint.
I’ve tried adding an extra ytick
for 0, and it horribly distorts the look of things, as expected. I also tried adding a "fake" data point (for which I could remove the dot(?)) in approximately the right place on the plot, but this is tedious, error-prone, and [frankly] dishonest.
I have made great strides with LaTeX through internet searches. However, in this case my google-fu fails me.
How can I get the plot to extend toward the origin (while the origin remains "offscreen")? To be clear, I would like the x/y windowing to remain how it is — I just want the plot to continue to the edge rather than stopping at the x=0.05
datapoint.
This code is probably a mess, so I apologize in advance for anything in here that’s done in a terrible way.
begin {figure}[H]
centering
begin{tikzpicture}
begin{axis}[
xlabel={$v_D$ (si{volt})},
ylabel={$i_D$ (si{ampere})},
ytick={0.00000001, 0.0000001, 0.000001, 0.00001, 0.0001, 0.001},
yticklabels={$SI{10}{nanoampere}$, $SI{100}{nanoampere}$, $SI{1}{microampere}$, $SI{10}{microampere}$, $SI{100}{microampere}$, $SI{1}{milliampere}$},
ymode=log,
ymajorgrids=true,
legend pos=outer north east,
]
addplot table{
-1.000 -1.429E-08
0 0.000E+00
0.05 2.343E-08
0.10 8.547E-08
0.15 2.497E-07
0.20 6.842E-07
0.25 1.831E-06
0.30 4.843E-06
0.35 1.265E-05
0.40 3.227E-05
0.45 7.824E-05
0.50 1.726E-04
0.55 3.340E-04
0.60 5.646E-04
0.65 8.532E-04
0.70 1.210E-03
};
addlegendentry{$i_D$}
% diagonal extension line
addplot[mark=none, black, dotted, line width = 1] coordinates {
(0, 2E-08) (0.45,7.824E-05)
};
end{axis}
end{tikzpicture}
caption{Finding $I_S$}
label{fig:3_is}
end {figure}
I have no time now to derive the diode equation parameters ?, but what about this?
You just substitute the correct current value for the point at $V_D=SI{0.01}{V}$ (btw, $v_{scriptscriptstyle D}$ looks better ;-), I even have a macro for it).
Then you manually fix the range (xmin=0, xmax=0.6, enlarge x limits, ymin=1e-8, ymax=4e-3
) and plot (I added smooth
but that's a matter of taste).
The key enlarge x limits
is used to have the same effect as the "expanded" x-axis you have.
The part of the graph going outside is automatically clipped (look at the description of the key clip mode
).
Obviously, you can do the same on the other side (add one value for 0.9 V, for example).
documentclass[border=10pt]{standalone}
usepackage{tikz, siunitx}
usepackage{pgfplots}pgfplotsset{compat=1.13}
begin{document}
begin{tikzpicture}
begin{axis}[
xmin=0, xmax=0.7, enlarge x limits,
ymin=1e-8, ymax=4e-3,
xlabel={$v_D$ (si{volt})},
ylabel={$i_D$ (si{ampere})},
ytick={0.00000001, 0.0000001, 0.000001, 0.00001, 0.0001, 0.001},
yticklabels={$SI{10}{nanoampere}$, $SI{100}{nanoampere}$, $SI{1}{microampere}$, $SI{10}{microampere}$, $SI{100}{microampere}$, $SI{1}{milliampere}$},
ymode=log,
ymajorgrids=true,
legend pos=outer north east,
]
% first point added semi-"randomly", substitute the correct value
addplot+[smooth] table{
0.01 4.0E-09
0.05 2.343E-08
0.10 8.547E-08
0.15 2.497E-07
0.20 6.842E-07
0.25 1.831E-06
0.30 4.843E-06
0.35 1.265E-05
0.40 3.227E-05
0.45 7.824E-05
0.50 1.726E-04
0.55 3.340E-04
0.60 5.646E-04
0.65 8.532E-04
0.70 1.210E-03
};
addlegendentry{$i_D$}
% diagonal extension line
% just to show that you can use TikZ normal drawing commands here
draw[mark=none, black, dotted, line width = 1]
(0, 2E-08) -- (0.45,7.824E-05);
end{axis}
end{tikzpicture}
end{document}
Answered by Rmano on February 6, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP