- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试绘制一些曲线,但效果不是很好。
\documentclass{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ticks=none,
xtick distance=1,
ytick distance=1,
axis equal image=true,
grid,
grid style={gray!50},
grid=both,
xlabel={$x$},
ylabel={$y$},
axis lines=middle,
xmin=-4, xmax=9, ymin=-5, ymax=4,
axis x line=center,
axis y line=center,
]
\addplot[thick, smooth] plot coordinates
{
(-3, -1)
(-.5, -3)
(.5, -1.9)
(1.5, -2.8)
(3.5, 1)
(5.5, 3)
(7.5, -1.95)
(8, -1.5)
};
\end{axis}
\end{tikzpicture}
\end{document}
是否可以在不添加大量点的情况下构建如此平滑的曲线?在原图中,您可以看到几个引用点。有什么方法可以配置 \addplot
或任何其他命令吗?
最佳答案
使用所有这些点(最后一个点除外)的梯度为零的附加信息,Bézier curves似乎比平滑的情节更适合。
所以,你可能会实现这种事情......
用这段代码...
\documentclass[border=2pt]{standalone}
\usepackage{fourier}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}[thick, line cap=round, >=latex, scale=0.5]
% Some constants for the Bezier curve
\def\x{0.5}
\def\u{1.0}
\def\v{0.3}
\def\w{0.1}
% The grid, axes and labels
\draw[thin, gray!20, help lines] (-4.5 ,-4.5) grid (9.5 ,4.5);
\draw[very thick, ->] (-4.5, 0) -- (9.8, 0) node[above] {$x$};
\draw[very thick, ->] (0, -4.5) -- (0, 4.8) node[left] {$y$};
\path (-3, 0) coordinate (x1) node[above] {$-3$}
(0, 0) coordinate (x2) node[below] {$\quad0$}
(1, 0) coordinate (x3)
(8, 0) coordinate (x4) node[below] {$8$}
(0, 1) coordinate (y1) node[right] {$1$};
% ticks are really cumbersome
\draw[very thick] ($(x1)+(0,-\w)$) -- ($(x1)+(0,\w)$);
\draw[very thick] ($(x3)+(0,-\w)$) -- ($(x3)+(0,\w)$);
\draw[very thick] ($(x4)+(0,-\w)$) -- ($(x4)+(0,\w)$);
\draw[very thick] ($(y1)+(-\w,0)$) -- ($(y1)+(\w,0)$);
% Finally, the points...
\path (-3, -1) coordinate (A)
(-.5,-3) coordinate (B)
(.5, -1.9) coordinate (C)
(1.5,-2.8) coordinate (D)
(3.5, 1) coordinate (E)
(5.5, 3) coordinate (F) node[above] {$y=F(x)$}
(7.5,-1.95) coordinate (G)
(8, -1.5) coordinate (H);
% and the line with suitable gradients (after a bit trial and error)
\draw[ultra thick]
(A) ..controls +(\u, 0) and ( $(B) + (-\x, 0)$ )..
(B) ..controls +(\x, 0) and ( $(C) + (-\v, 0)$ )..
(C) ..controls +(\v, 0) and ( $(D) + (-\v, 0)$ )..
(D) ..controls +(\x, 0) and ( $(E) + (-\u, 0)$ )..
(E) ..controls +(\u, 0) and ( $(F) + (-\x, 0)$ )..
(F) ..controls +(\x, 0) and ( $(G) + (-\u, 0)$ )..
(G) ..controls +(\w, 0) and ( $(H) + (-\w,-\v)$ )..
(H);
% two small circles to mark the curve ends
\draw[thin, fill=white] (A) circle (3pt);
\draw[thin, fill=white] (H) circle (3pt);
\end{tikzpicture}
\end{document}
关于tikz - 使用 Tikz 精确平滑的曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59880248/
我正在尝试绘制一些曲线,但效果不是很好。 我需要什么 我得到了什么 \documentclass{standalone} \usepackage{tikz} \usepackage{pgfplots}
我正在尝试使用 Tikz 包绘制(无向)图,以便图中的某些节点之间存在多条边。有可能做这样的事情吗?我尝试了以下代码来尝试在节点之间获得至少两条边,但无济于事: \begin{tikzpicture}
我有一张tikz图片: \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{positioning, shapes, shadow
我正在尝试 quarto对于我的幻灯片,想知道如何在 tkiz 中使用 \pause代码。最低工作示例如下,供引用。 --- title: "Test Slides" format: reveal
假设我想在 TikZ 中构建一个循环图,节点数量可变,标记为 v0、v1、...、v_n-1,我选择了一些 n(比如 5)。 我希望能够在 TikZ 中使用\foreach 命令迭代地 (1) 定义节
这个问题是由here问题引起的 我想产生一个跨大括号的花括号。 问题是我必须手动对齐x坐标,这不是一个干净的解决方案。 目前我使用 \begin{frame}{Example} \begin{item
我想拍一张 PGF 图片,将其缩小(也可以缩放文本,所以 \resizebox 将是完美的)以获得一定的高度,然后在图片的左侧放置一个旋转的文本并创建一个包含所有内容的节点。 像这样的东西: 但我希望
我有这个阴影圆圈: \shade [ball color=black!80!white] (0,0) circle (1); 是否可以用node样式封装? (包括固定圆半径?) 最佳答案 \node[
我正在尝试使用宏来构建我的树,但我没有得到我想要的结果。这是一个最小的例子: \documentclass{article}\usepackage{tikz}\usetikzlibrary{trees
尽管图表足够宽(轴线样式),但以下图表的外部列被切掉了。设置图表的宽度也无济于事。任何想法?增加条形宽度需要设置或放大什么? \begin{tikzpicture} \begin{axis}[
如何在 Mac Os X(10.6.8) 上的 gnuplot 中启用 tikz 终端? 我有工作 tikz 的 latex 。现在我从 http://www.lua.org/ 安装了 lua并下载g
我可以使用\path 绘制一条穿过 2 条边的线吗? 考虑: \documentclass{article} \usepackage{tikz} \usetikzlibrary{positioning
这里有人是 Tikz-timing 方面的大师吗? 我正在寻找一种用注释来标记时序图的方法,但垂直比例太压缩了。我找不到\timing 命令的完整选项列表(或者即使找到了,也只是一个微薄的列表)。 我
我需要将图表的每一行与中心对齐。我正在尝试用 xshift 来做到这一点。代码如下: \begin{tikzpicture}[node distance=1.5cm, auto, text c
我想弄清楚如何在 tikz 中的节点和其他两个节点之间的边缘标签之间绘制一条边。这是我正在尝试做的一个例子: 这是我的代码: \documentclass[11pt]{article} \usepac
这是一个后续问题 here .如图所示,我需要制作一个圆形灰色框。 根据答案,我尝试了一些东西,但没有那么富有成效。所以,另一个问题来了。 我想出了以下命令,但它不起作用。 minipage 中的逐字
我的 R 包小插图使用 tikz/pgf 图形。 R CMD check 命令在未安装 LaTeX 包 tikz/pgf 的操作系统上抛出错误消息。例如,在 vanilla Ubuntu 系统上,必须
这就是我想要做的 \begin{tikzpicture} [node distance = 1cm, auto,font=\footnotesize, % STYLES
我是第一次用TikZ,不知道这个分类图怎么画。 我只绘制了 2 列,代码如下: \documentclass{article} \usepackage{tikz} \usetikzlibrary{sh
是否有一种简单的方法可以使用以下内容增加箭头提示的大小: \tikzset{myptr/.style=->, ????} 没有从头开始设计新的箭头样式? 最佳答案 一种解决方案,非常快,只是缩放箭头是
我是一名优秀的程序员,十分优秀!