标签: tikz

Tikz:如何在节点中封装阴影?

我有这个阴影圆圈:

\shade [ball color=black!80!white] (0,0) circle (1);
Run Code Online (Sandbox Code Playgroud)

能不能用node风格封装一下?
(包括固定圆半径?)

latex tikz

3
推荐指数
1
解决办法
4188
查看次数

使用tikz绘制彼此之间具有多个边的图

我试图使用Tikz包绘制(无向)图形,这样图形中的某些节点之间存在多个边缘.有可能做这样的事吗?我尝试了以下代码尝试在节点之间获得至少两个边缘,但无济于事:

\begin{tikzpicture}
[scale=.8,auto=left,every node/.style={circle,fill=blue!20}]
\node (nA) at (1,10) {A};
\node (nB) at (9,10) {B};
\node (nC) at (5,8)  {C};
\node (nD) at (5,6)  {D};

\foreach \from/\to in {nA/nC,nA/nD,nC/nB,nD/nB,nC/nA,nD/nA,nB/nD,nB/nC}
\draw (\from)--(\to);
\end{tikzpicture}
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个问题吗?谢谢!

tikz

3
推荐指数
1
解决办法
7197
查看次数

在Latex Tikz库中的节点文本中输入换行符

我刚刚开始使用Latex生成大量数学文档。我想包含一个概率树,并找到了Tikz库。我的树的第一部分代码如下所示:

%To create probability trees, use tikz package
\usepackage{tikz}
\usetikzlibrary{trees}

% Insert a probability tree showing first level only
% -------------------------------------------------------------
% Set the overall layout of the tree
\tikzstyle{level 1}=[level distance=3.5cm, sibling distance=4.0cm]
\tikzstyle{level 2}=[level distance=3.5cm, sibling distance=2cm]

% Define styles for bags and leafs
\tikzstyle{bag} = [text centered]

% Draw probability tree
\begin{tikzpicture}[grow=right, sloped]
\node[bag] {}
    child {
        node[bag] {Not diseased $\left( D^- \right)$}
            edge from parent 
            node[below]  {$0.90$}
    }
    child {
        node[bag] {Diseased $\left( D^+ \right)$}        
            edge …
Run Code Online (Sandbox Code Playgroud)

latex tikz

3
推荐指数
2
解决办法
7386
查看次数

LaTeX 中 tikzDevice 和 ggplot2 生成的标题和图形之间的空白过多

我目前正在使用 Rggplot2tikzDevice包来生成图形并在文档中介绍它们LaTeX,但我正在努力解决图形和标题之间产生的大空白,正如您在比较图像时看到的那样(我已手动突出显示空格以使其更清晰):

ggplot2 绘图 tikz图

这是我的 MWE:

R代码:

library(ggplot2)
library(tikzDevice)

set.seed(1)
x <- rnorm(200)

tikz(file = "Rplots.tex", width = 4, height = 4)
qplot(x, geom = "histogram")
dev.off()
Run Code Online (Sandbox Code Playgroud)

和乳胶代码:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{figure}
\centering
\include{Rplots}
\caption{\texttt{ggplot2} plot.}
\end{figure}

\begin{figure}
\centering
\begin{tikzpicture}[scale=3]
    \clip (-0.1,-0.2)
    rectangle (1.8,1.2);
    \draw[step=.25cm,gray,very thin]
    (-1.4,-1.4) grid (3.4,3.4);
    \draw (-1.5,0) -- (2.5,0);
    \draw (0,-1.5) -- (0,1.5);
    \draw (0,0) circle (1cm);
    \filldraw[fill=green!20!white,
    draw=green!50!black]
    (0,0) -- (3mm,0mm)
    arc (0:30:3mm) -- cycle;
\end{tikzpicture}
\caption{\texttt{tikz} plot.}
\end{figure}

\end{document}
Run Code Online (Sandbox Code Playgroud)

我想知道如何 …

latex r tikz ggplot2

3
推荐指数
1
解决办法
9223
查看次数

Tikz 轴图外列被切断

尽管图表足够宽(轴线样式),但以下图表的外列被截断。设置图表的宽度也无济于事。任何的想法?增加条宽时需要设置或放大什么?

\begin{tikzpicture}
    \begin{axis}[
    ybar, 
    bar width=0.6cm,
    tick align=inside,
    major grid style={draw=white},
    enlarge y limits={value=.1,upper},
    ymin=0, ymax=100,
    axis x line*=bottom,
    axis y line*=right,
    hide y axis,axis line style={shorten >=-15pt, shorten <=-15pt},
    symbolic x coords={Total, Women, Men},
    xtick=data,
    nodes near coords={\pgfmathprintnumber[precision=0]{\pgfplotspointmeta} }
    ]
    \addplot [draw=none, fill=blue!30] coordinates {
        (Total,75.4064)
        (Women, 72.7961) 
        (Men,94.4597) };
    \addplot [draw=none,fill=red!30] coordinates {
        (Total,75.4064)
        (Women, 89.7961) 
        (Men,94.4597) };
    \addplot [draw=none, fill=green!30] coordinates {
        (Total,75.4064)
        (Women, 89.7961) 
        (Men,94.4597) };
    \legend{}
    \end{axis}
\end{tikzpicture}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

charts latex tikz

3
推荐指数
1
解决办法
2869
查看次数

如何在不缩放文本的情况下缩放 tikz 中的条形图?

我在 tikz 的乳胶中有一个条形图,我想缩放它(减少宽度,增加长度),但文本没有相同的效果。

\begin{figure}
\centering
\resizebox{0.8\textwidth}{1.3\textwidth}{
\begin{tikzpicture}
\pgfplotsset{every tick label/.append style={font=\tiny}}
\begin{axis}[ xmajorgrids=true,
xbar, xmin=0,
xlabel={Gini Coefficient, OECD Countries \%},
symbolic y coords={{Australia},{Austria},{Belgium},{Canada},{Chile},{Costa Rica},{Czech Republic},{Denmark},{Estonia},{Finland},{France},{Germany},{Greece},{Hungary},{Iceland},{Ireland},{Israel},{Italy},{Japan},{Korea},{Latvia},{Lithuania},{Luxembourg},{Mexico},{Netherlands},{New Zealand},{Norway},{Poland},{Portugal},{Slovak Republic},{Slovenia},{South Africa},{Spain},{Sweden},{Switzerland},{Turkey},{United Kingdom},{United States}},
ytick=data,
nodes near coords, nodes near coords align={horizontal},
ytick=data,
]
\addplot[fill=blue!90,draw=black!70,tickwidth = 0pt,bar width=4pt,label style={font=\small}, tick label style={font=\small}] coordinates {(0.33,{Australia}) (0.284,{Austria}) (0.266,{Belgium}) (0.307,{Canada}) (0.454,{Chile}) (0.48,{Costa Rica}) (0.253,{Czech Republic}) (0.263,{Denmark}) (0.314,{Estonia}) (0.266,{Finland}) (0.291,{France}) (0.294,{Germany}) (0.333,{Greece}) (0.288,{Hungary}) (0.255,{Iceland}) (0.297,{Ireland}) (0.344,{Israel}) (0.328,{Italy}) (0.339,{Japan}) (0.355,{Korea}) (0.346,{Latvia}) (0.378,{Lithuania}) (0.304,{Luxembourg}) (0.458,{Mexico}) (0.285,{Netherlands}) (0.349,{New Zealand}) (0.262,{Norway}) (0.284,{Poland}) …
Run Code Online (Sandbox Code Playgroud)

text latex scale tikz bar-chart

3
推荐指数
1
解决办法
8520
查看次数

LaTex/tikZ:如何从南2个节点到北1个节点绘制2个垂直箭头?

如何从变量2和变量3的节点向变量1绘制垂直箭头?

\documentclass[jou]{apa7}
\usepackage{tikz}
\usepackage{fixltx2e}
\usetikzlibrary{shapes, shadows, arrows}
\usetikzlibrary{positioning}
\tikzset{mynode/.style={shape=rectangle, draw, align=center}
}

\begin{document}

\begin{figure*}
\begin{tikzpicture}
\node[mynode, text width=7cm,minimum height=1cm] (v1){Variable 1};
\node[mynode,above left= 2cm of v1, text width = 4cm, minimum height = 1cm, xshift=4cm](v2) {Variable 2};
\node[mynode,above right= 2cm of v1, text width=4cm, minimum height = 1cm, xshift=-4cm] (v3){Variable 3};

\draw[-latex] (v2.south) -- (v1.north);
\draw[-latex] (v3.south) -- (v1.north);
 
\end{tikzpicture}
\end{figure*}

\end{document}
Run Code Online (Sandbox Code Playgroud)

使用上面的代码输出:

在此输入图像描述

期望的输出:

在此输入图像描述

latex tikz

3
推荐指数
1
解决办法
7449
查看次数

Tikz-timing选项的综合列表

这里有人是Tikz-timing的大师吗?

我正在寻找一种用注释标记时序图的方法,但是垂直标度太压缩了.我找不到\ timing命令的全面选项列表(或者如果我这样做,它只是一个微薄的列表).

我最初猜测它们可能会失败(例如height =),但最终我偶然发现了一个证明yscale =应该工作的文档的例子,所以它确实如此.

这是一个代码片段,可以帮助您入门:

\begin{tikzpicture}
    \timing [yscale=2.0] at (0,0)  {3H N (d7) 3L 3H N (d6) 3L 3H N (d5) 3L 3H N (d4) 3L 3H N (d3)3 L 3H N (d2) 3L 3H N (d1) 3L 3H N (d0) 3L 3H N (ack) 3L};
    \path (d7) node [below left] {D7};
    \path (d6) node [below left] {D6};
    \path (d5) node [below left] {D5};
    \path (d4) node [below left] {D4};
    \path (d3) node [below left] {D3};
    \path (d2) …
Run Code Online (Sandbox Code Playgroud)

latex tikz timing-diagram

2
推荐指数
1
解决办法
1686
查看次数

ggplot2 和 TikzDevice - 去除空白

我正在使用tikzDevice包来获取R. 我无法从下图的顶部和底部删除过多的空白: 例子

我试过使用,par(mar)但它似乎不适用于ggplot2. 此外,theme(plot.margins)似乎也没有反应。当我尝试用 改变图形的纵横比时引入了空白theme(aspect.ratio)。有什么建议?谢谢!

编辑:这是一个 MWE:

library(tikzDevice)
library(reshape2)
x = seq(0,1,0.1)
y1 = x^2+2*x+7
y2= x^+2*x+2

df = data.frame(x,y1,y2)
df <- melt(df, id.vars=c("x"))
names(df) <- c("x","$latex~Name$","value")
plot <- ggplot(df,aes(x=x,y=value,color=`$latex~Name$`,group=`$latex~Name$`)) + geom_line() +
  theme(aspect.ratio = 0.4)
plot

tikzDevice(file="mweTex.tex")
plot
dev.off()
Run Code Online (Sandbox Code Playgroud)

r tikz ggplot2

2
推荐指数
1
解决办法
688
查看次数

tikz:剪切范围的相对位置

我试图将一些tikz图组成一个更大的概览图,但是我很难将子图像相对于其父对象以及彼此对齐。

使用scope和从其他tikz图形中以矩形形状裁剪出子图像clip

红蓝色矩形

\documentclass[crop,tikz]{standalone}
\usepackage{relsize, xcolor, tikz}

\begin{document}

\begin{tikzpicture}[x=0.04cm,y=-0.04cm]

    \begin{scope}[xshift=0, yshift=0, local bounding box=scopeAouter]
        \fill [black!40, rounded corners=5] (0, 0) rectangle ++(60, 70);  % bounding rectangle
        \begin{scope}[xshift=0, yshift=0, scale=.5, local bounding box=scopeAinner]
            \clip [rounded corners=3] (-30, -5) rectangle ++(100, 50);  % cannot change this line
            % dummy pattern
            \fill [red!60] (-100,-100) rectangle (100, 100);
            \fill [blue!60] (-100, -100) -- (100, -100) -- (100, 100) -- cycle;
        \end{scope}
    \end{scope}

    \begin{scope}[xshift=80, yshift=0, local bounding box=scopeBouter]
        \fill [black!40, rounded corners=5] …
Run Code Online (Sandbox Code Playgroud)

layout latex scope tikz

2
推荐指数
1
解决办法
90
查看次数

GNUPlot中的高分辨率散点图?

我通常tikz-pgfplot通过gnuplot-lua界面来绘制研究论文的科学数据.它通常非常好,我可以将我的数字无缝地整合到latex文档中.由此产生的数字是非常高的分辨率和精细的.然而,绊脚石是大数据集的高分辨率散点图 - 调整100,000点.

如果我按照我的惯常tikz-pgfplot路线latex生成文件,但在编译时pdflatex,会得到tex memory exceeded...错误.我也知道增加tex记忆并不是一个好主意.所以,我最终生成了一个eps(封装的postscript)图,然后我将其包含在我的latex文档中tikz-pgfplot以呈现注释.它通常可以工作,但会产生一个非常大的PDF文件,2 MB以便为一个小图而且PDF读者需要很长时间才能完全显示图形.

我想知道,是否还有其他方法可以生成大型数据集的高分辨率散点图?任何指针都将受到高度赞赏.

Madhur

pdf-generation gnuplot scatter-plot pdflatex tikz

1
推荐指数
1
解决办法
158
查看次数

使用 Latex 创建 Wifi 信号条

有谁知道如何使用 Latex 创建以下图标(我猜是 tikz)

在此处输入图片说明

有了一些newcommand,我可以选择要在 tex 文档中从 0 到 4 填充的条。

类似于他们在此处定义的命令:文本中的内嵌图形表示 CV 中语言技能的加载条,而不是绘制此 wifi 条的圆圈。

谢谢!

latex tikz

0
推荐指数
1
解决办法
60
查看次数