
다음 다이어그램이 있는데 빨간색 선을 확장하여 축을 교차하고 두 번째 그림과 같이 시작과 끝에서 약간 계속 진행하고 싶지만 빨간색과 파란색 점이 여전히 수직으로 정렬되도록 하고 싶습니다. . 또한 연장된 빨간색 선은 상단 축 위에서 끝나야 합니다.
\documentclass{article}
\usepackage{pgf}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{figure} [tb]%
\centering
\begin{tikzpicture}
\begin{semilogxaxis}[
enlarge y limits=true,
enlarge x limits=false]
\addplot[very thick,draw=blue!70, mark=*,mark options={color=blue!70}] coordinates
{(229,62) (1475,122) (23598,255) (27101,272) (32427,280) (55124,322) (758667,5509) (1273808,5649) (1406902,6375)};
\end{semilogxaxis}
\begin{semilogxaxis}[
smooth,
axis y line=none,
axis x line=none,
ticks=none,
enlarge y limits=true,
enlarge x limits=false]
\addplot[very thick,draw=red!70] expression[domain=229:1406902] {x};
\addplot[draw=none,mark=*,mark options={color=red!70}] coordinates
{(229,229) (1475,1475) (23598,23598) (27101,27101) (32427,32427) (55124,55124) (758667,758667) (1273808,1273808) (1406902,1406902)};
\end{semilogxaxis}
\end{tikzpicture}
\caption{Caption}
\end{figure}
\end{document}
두 번째 세미로그축의 너비와 높이를 변경하고 내부 곡선의 영역을 변경해 보았지만 점을 수직으로 정렬할 수 없습니다.
또한 a를 사용하려고 시도했지만 오류 \draw[domain=0:2000000,smooth,variable=\x] plot (axis cs:\x,\x);
가 발생 하고 tikz에서 FPU(부동 소수점 단위)를 사용 Dimension too large
하도록 관리할 수 없습니다 .\draw plot
답변1
플롯 후 계속 그림을 그릴 수 있으며 특수 좌표를 활용할 수 있습니다 current plot end/begin
. 더미 좌표를 끝과 시작에 매우 가깝게 배치하면 접선 근사치를 모방할 수 있습니다. 하지만 축의 클리핑 동작을 꺼야 합니다. 보다점선 추세선을 추가하기 위해 플롯 내의 선 스타일을 변경하시겠습니까?플롯이 너무 펑키하지 않은 경우 특정 경우에 더 나을 수 있는 노드 모양을 가진 유사한 솔루션의 경우.
\documentclass{article}
%\usepackage{pgf}
%\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc}
\begin{document}
\begin{figure} [tb]%
\centering
\begin{tikzpicture}
\begin{semilogxaxis}[
enlarge y limits=true,clip=false,
enlarge x limits=false]
\addplot[very thick,draw=blue!70, mark=*,mark options={color=blue!70}] coordinates
{(229,62) (1475,122) (23598,255) (27101,272) (32427,280) (55124,322) (758667,5509) (1273808,5649) (1406902,6375)};
\end{semilogxaxis}
\begin{semilogxaxis}[
smooth,clip=false,
axis y line=none,
axis x line=none,
ticks=none,
enlarge y limits=true,
enlarge x limits=false]
\addplot[very thick,draw=red!70] expression[domain=229:1406902] {x}
coordinate [pos=0.98] (c2) coordinate [pos=0.01] (c3) (current plot end) -- ($(c2)!10!(current plot end)$)
(current plot begin) -- ($(c3)!1.2!(current plot begin)$);
\addplot[draw=none,mark=*,mark options={color=red!70}] coordinates
{(229,229) (1475,1475) (23598,23598) (27101,27101) (32427,32427) (55124,55124) (758667,758667) (1273808,1273808) (1406902,1406902)};
\end{semilogxaxis}
\end{tikzpicture}
\caption{Caption}
\end{figure}
\end{document}