在节点修改中插入长文本

在节点修改中插入长文本

使用以下答案中的代码这个问题

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}
\tikzset{%
declare function={
myslope(\x) = 20 - \x*(20/20);
},
}
\begin{tikzpicture}[
 dot/.style = {circle, black, inner sep=0, minimum size=6pt, fill, node contents={}},
 pinlabel/.style={text width=35mm, color=black, fill=yellow!20, xshift=0cm, yshift=0cm, outer sep=0pt, inner sep=5pt},
 pinstyle/.style={pin distance=10mm},
 every pin edge/.style={black, very thick, shorten >=-20pt},
 aligned pin/.style args={[#1]#2:#3}%
  {pin={[pinstyle,
  label={[append after command={%
  node[pinlabel,%
    at=(\tikzlastnode.#2),
    anchor=#1,
          ]{#3}}]center:{}}
        ]#2:{}}%
  },
scale=.9, transform shape]
\begin{axis}[
 axis lines=center, axis line style={black, thick,-latex},%
 axis y line=left, axis x line=bottom,
 tick style={line width=.04cm, color=black, line cap=round},%
 font=\normalsize, color=black,%
 xmin=0, xmax=21,
 xtick={0,10}, xticklabels={0,10},
 ymin=0, ymax=21,
 ytick={10}, yticklabels={10},
 tickwidth=.01cm,%
 xlabel={$A$},
 xlabel style={xshift=.62cm, yshift=0cm}, xlabel style={right},
 ylabel={$O$},
 ylabel style={xshift=0cm, yshift=.46cm}, ylabel style={above},
 xticklabel style={inner xsep=0cm, xshift=0cm, yshift=-.1cm},
 yticklabel style={inner ysep=0cm, xshift=-.1cm, yshift=0cm},
]
\draw [thick, black, densely dashed] (axis cs:0,{myslope(10)}) -- (axis cs:10,{myslope(10)}) node [black, xshift=.46cm, yshift=.05cm] {$$} -- (axis cs:10,0);

\addplot [ultra thick, blue, dashed, samples at={10}, mark=*, mark options={blue, solid}, mark size=.12cm] {myslope(x)};

\addplot [ultra thick, blue, dashed, samples at={0,10,20}, mark=*, mark options={blue, solid}, mark size=.12cm,-latex] {myslope(x)};

\scoped[pinlabel/.append style={text width=20mm}, pinstyle/.append style={pin distance=8mm}] 
 \node at (axis cs:10,{myslope(10)}) [dot, aligned pin={[north west, xshift=.2cm, yshift=.4cm]65:bla bla bla bla}] {};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

这让我

这幅画

如何进行以下修改以使其看起来像

这幅画

  1. 在位置 10,10 上做出不同大小和颜色的标记。
  2. 在文本周围画一个框架。
  3. 使图钉以一定角度显示。

答案1

我并不pins经常使用,相反,我会将\node它与 连接起来\draw

要更改位置 (10,10) 处的标记的颜色,请调整mark中的颜色samples at={10}。您还可以使用后续内容覆盖此内容samples at={0,10,20}(我将其更正为samples at={0,20}

要添加文本周围的框架,请指定draw=<color>选项\node

是尝试从图中所示的近似位置的框(X.170)开始绘制线条。我个人会改用。如果您不想从节点开始,您可以改用将起点向左移动。bla(X.west)([xshift=-5pt]X.170)5pt

在此处输入图片描述

代码:

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[fragile,t]
\frametitle{1}
\tikzset{%
declare function={
myslope(\x) = 20 - \x*(20/20);
},
}
\begin{tikzpicture}[
 dot/.style = {circle, black, inner sep=0, minimum size=6pt, fill, node contents={}},
 pinlabel/.style={text width=35mm, color=black, fill=yellow!20, xshift=0cm, yshift=0cm, outer sep=0pt, inner sep=5pt},
 pinstyle/.style={pin distance=10mm},
 every pin edge/.style={black, very thick, shorten >=-20pt},
 aligned pin/.style args={[#1]#2:#3}%
  {pin={[pinstyle,
  label={[append after command={%
  node[pinlabel,%
    at=(\tikzlastnode.#2),
    anchor=#1,
          ]{#3}}]center:{}}
        ]#2:{}}%
  },
scale=.9, transform shape]
\begin{axis}[
 axis lines=center, axis line style={black, thick,-latex},%
 axis y line=left, axis x line=bottom,
 tick style={line width=.04cm, color=black, line cap=round},%
 font=\normalsize, color=black,%
 xmin=0, xmax=21,
 xtick={0,10}, xticklabels={0,10},
 ymin=0, ymax=21,
 ytick={10}, yticklabels={10},
 tickwidth=.01cm,%
 xlabel={$A$},
 xlabel style={xshift=.62cm, yshift=0cm}, xlabel style={right},
 ylabel={$O$},
 ylabel style={xshift=0cm, yshift=.46cm}, ylabel style={above},
 xticklabel style={inner xsep=0cm, xshift=0cm, yshift=-.1cm},
 yticklabel style={inner ysep=0cm, xshift=-.1cm, yshift=0cm},
]
\draw [thick, black, densely dashed] (axis cs:0,{myslope(10)}) -- (axis cs:10,{myslope(10)}) node [black, xshift=.46cm, yshift=.05cm] {$$} -- (axis cs:10,0);

\addplot [ultra thick, blue, dashed, samples at={10}, mark=*, mark options={orange, solid}, mark size=.12cm] {myslope(x)};

\addplot [ultra thick, blue, dashed, samples at={0,20}, mark=*, mark options={blue, solid}, mark size=.12cm,-latex] {myslope(x)};

%\scoped[pinlabel/.append style={text width=20mm}, pinstyle/.append style={pin distance=8mm}] 
% \node at (axis cs:10,{myslope(10)}) [dot, aligned pin={[north west, xshift=.2cm, yshift=.4cm, draw=red]35:bla bla bla bla}] {};
 
 \node [text width=20mm, draw=red, fill=yellow!20] (X) at ([shift={(35:2.5cm)}]axis cs:10,{myslope(10)})  {bla bla bla bla};
 
 \draw (X.170) -- ++(-0.5cm,0) -- (axis cs:10,{myslope(10)});
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

相关内容