Pgfplot을 사용한 재현 그림

Pgfplot을 사용한 재현 그림

여러분의 도움이 필요합니다. 설명하려면 이 그림을 재현해야 합니다.피크 초과 임계값 방법(냄비)여기에 이미지 설명을 입력하세요Pgfplot을 사용하여 당신의 응답을 주셔서 감사합니다.

답변1

여기에 예가 있습니다. 코드에는 여러 가지 설명이 포함되어 있습니다. 불분명한 부분이 있으면 문의해 주세요.

\documentclass[border=5mm]{standalone}
\usepackage{pgfplotstable} % also loads pgfplots

% make a table containing y-values and labels for (some of) the data points
\pgfplotstableread[col sep=comma]{
y,label
8,$Y_{1}$
2,
5.6,$Y_{2}$
5,$Y_{3}$
6,
4,
9,$Y_{j}$
10,
4,
}\mydata

\begin{document}
\begin{tikzpicture}
\begin{axis}[
  % 
  axis lines=middle,
  % labels for axes
  ylabel={$X_i$},
  xlabel={$i$},
  % set axes limits
  ymin=0,
  xmin=0,
  xmax=9.9,
  % define where to place ticks on the axes
  % and what text labels to use for the ticks
  ytick={4.5},
  yticklabels={$u$},
  xtick={1,2,3,9},
  xticklabels={$1$,$2$,$3$,$n$},
  tickwidth=0pt,
  % turn on grid lines for ticks on the y-axis
  ymajorgrids,
  % set the style of the single grid line
  grid style={densely dotted, gray}
]

\addplot [
   % comb plots are lines from the axis to the point
   ycomb,
   thick,
   % nodes near coords is for adding automatic labels at data points
   nodes near coords,
   % set the style of those nodes
   nodes near coords style={font=\small},
   % the following states that the text used for the labels should
   % be given explicitly in the data stream
   % symbolic means that it should not be parsed as a number
   point meta=explicit symbolic
 ]
 table[
    % define the x-coordinate
    x expr=\coordindex+1,
    % get y-values from the column named y in the table
    y=y,
    % get the data for the point labels from the column named label
    meta=label
  ] {\mydata};

\addplot [
   ycomb,
   thick,
   gray
 ]
 table[
    x expr=\coordindex+1,
    % the y-coordinate is defined  by the given calculation, i.e.
    % the smallest value of the y-value from the table and 4.5
    y expr={min(\thisrow{y}, 4.5)}
  ] {\mydata};

\end{axis}
\end{tikzpicture}

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보