我正在学习使用Jupyter/IPython Notebook作为电子笔记本.有时我需要简单的插图来配合我的计算,例如箭头来表示矢量.如果我们在Latex中,这就是TikZ的用途.尝试过TikZ魔术扩展并失败后,我想知道是否有更多原生(Python)方法可以做到这一点.我没有看到Matplotlib是这种事情的正确工具(如果我错了,请纠正我).
如果你认为TikZ魔法确实是要走的路,我应该尝试让它发挥作用,那么就这么说吧.谢谢.
我需要将图形的每一行与中心对齐.我试图用xshift做到这一点.这里的代码:
\begin{tikzpicture}[node distance=1.5cm, auto, text centered]
\tikzstyle{every node}=[draw,ball];
\begin{scope}[xshift=1.5cm]
\node (A) {A};
\node [right of=A] (B) {B};
\node [right of=B] (C) {C};
\node [right of=C] (D) {D};
\end{scope}
\begin{scope}[yshift=-1.5cm]
\node (AB) {AB};
\node [right of=AB] (AC) {AC};
\node [right of=AC] (AD) {AD};
\node [right of=AD] (BC) {BC};
\node [right of=BC] (BD) {BD};
\node [right of=BD] (CD) {CD};
\end{scope}
\begin{scope}[yshift=-3cm,node distance=2cm,xshift=1cm]
\node (ABC) {ABC};
\node [right of=ABC] (ABD) {ABD};
\node [right of=ABD] (ACD) {ACD};
\node [right of=ACD] (BCD) {BCD};
\end{scope}
\begin{scope}[xshift=4cm, …
Run Code Online (Sandbox Code Playgroud) 为CS理论分配绘制图形和树的最简单,最清晰的方法是什么?
我对以下任何解决方案都不满意:
是否有人专门为此任务编写软件?
谢谢!
我一直在使用带有R基本图形和tikz输出的knitr一段时间,并且想要尝试一下ggplot2
.但是,这个最小的例子无法使用knitr 1.0.5产生任何输出:
\documentclass{article}
\begin{document}
<<dev = 'tikz'>>=
library(ggplot2)
d = data.frame(a = c(1, 2, 3), b = c(4, 5, 6), c = c(7, 8, 9))
ggplot(d, aes(a, b, color = c)) + geom_point()
@
\end{document}
Run Code Online (Sandbox Code Playgroud)
相反,它失败了Error in UseMethod("depth"): no applicable method for 'depth' applied to an object of class "NULL"
.在R中执行代码或选择png设备将产生预期的图形.省略颜色美学或c
使用tikzDevice进行因子分解工作,因此连续色标似乎是个问题.
有什么我做错了,还是那个错误?
我正在尝试使用\ ifthenelse进行浮点比较.这是pgf/tikz代码,如果\ y只是整数,则可以工作,但不是这样:
\foreach \y in {3,3.5,...,6} {
ifthenelse{\y<3}{
...
}{
...
}
}
Run Code Online (Sandbox Code Playgroud) 问题: 有没有办法在Rmarkdown文档中使用tikz表示法而无需将文档编译为pdf?
而且(有点朝同一方向):
问题: 在我想要编译为html的RMarkdown文档中添加多个tikz图形的最佳方法是什么(同时保持flexibilty将文件编译为pdf或后期的单词)?
我已经阅读了很多帖子的答案(比如R Markdown中的TikZ或者我如何使用TikZ制作独立(SVG)图形?),这些答案提出了类似的问题,但我仍然不完全确定,因此问题.
我基本上想要运行这段代码
---
output: pdf_document
header-includes:
- \usepackage{tikz}
---
## TikZ picture
Some picture
\begin{tikzpicture}
\draw (0,0) circle (2cm);
\end{tikzpicture}
Run Code Online (Sandbox Code Playgroud)
而不是pdf_document
我想要html_document
+一些魔法自动将tikz图形转换为html可以理解的东西.有什么建议?
我对Tikz/Latex有以下问题:
我有一些包含文本的节点.大多数文本没有低于基线的字母.但对于发生这种情况的节点,节点高度和文本/基线的比率和位置是关闭的.看看示例图像.
我知道的解决方案:
我有相当大的Latex文档,里面有很多TikZ数字.我有一个经常重新编译的习惯,使用pdflatex编译它需要花费很长时间.TikZ的数据占据了大部分时间.
我的问题是,将文档拆分为单独的tex文件(图/章)以实现图形和章节的单独编译,单独的pdf文章和整个文档pdf文件的最佳方法是什么?
我正在使用pgf/tikz图形,我想知道在minipage/subfig环境中使用它们时如何控制图形中字体大小的缩放?
有没有办法手动设置pgf/tikz图形或乳胶中的永久字体大小,以便使字体大小不变为缩放?
理想情况下,我希望能够为每个图形或所有图形或子图形/小型化环境手动指定字体大小?
以下是建议使用的示例.谢谢您的帮助.
\begin{figure}[h]
\centering
\subfloat[Graph 1]{
\begin{minipage}[h]{0.7\linewidth}
\centering\beginpgfgraphicnamed{graph1}
\input{graph1.tex}
\endpgfgraphicnamed
\label{fig:graph1}
\end{minipage}}
\hspace{5pt}
\subfloat[Graph 2]{
\begin{minipage}[h]{0.5\linewidth}
\centering\beginpgfgraphicnamed{graph2}
\input{graph2.tex}
\endpgfgraphicnamed
\label{fig:graph2}
\end{minipage}}
\subfloat[Graph 3]{
\begin{minipage}[h]{0.5\linewidth}
\centering\beginpgfgraphicnamed{graph3}
\input{graph3.tex}
\endpgfgraphicnamed
\label{fig:graph3}
\end{minipage}}
\caption{Three Graphs}
\end{figure}
Run Code Online (Sandbox Code Playgroud)
也许在minipage/subfig之外我可以使用其他帖子的建议来使字体变大,因为图形是用页面宽度缩放的?在这个例子中我想要的是它自己的第一个图像,更大,然后是两个小图像,并排在一个图中,并排在一起.
我在你的个人资料Mica中看到了一些R标签.图形是使用tikzDevice生成的,并在我的latex文档中提取.
所以我在没有tikzpicture环境的情况下生成文件,以便我可以自己手动设置选项.当我使用时,\begin{tikzpicture} \end{tikzpicture}
我得到错误"尺寸太大我不能使用大于19英尺的尺寸.继续,我将使用我能够的最大值." .我需要用\beginpgfgraphicnamed{} .. \endpgfgraphicnamed{}
它才能让它工作?不确定影响究竟是什么.
以下是自动生成文件的示例:
\begin{scope}
\path[clip] ( 0.00, 0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}
\begin{scope}
\path[clip] ( 0.00, 0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\end{scope}
Run Code Online (Sandbox Code Playgroud)
........
\begin{scope}
\path[clip] ( 0.00, 0.00) rectangle (794.97,614.29);
\definecolor[named]{drawColor}{rgb}{0.13,0.76,0.43}
\definecolor[named]{fillColor}{rgb}{0.31,0.94,0.66}
\definecolor[named]{fillColor}{rgb}{1.00,1.00,1.00}
\draw[fill=fillColor,draw opacity=0.00,] …
Run Code Online (Sandbox Code Playgroud) 我试图弄清楚如何在 tikz 中的节点和其他两个节点之间的边缘标签之间绘制边缘。这是我正在尝试做的事情的一个例子:
这是我的代码:
\documentclass[11pt]{article}
\usepackage[margin=1in, top=1.5in]{geometry}
\usepackage{amsmath,amssymb,bbm}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{arrows, positioning}
\setlength{\parindent}{0.25in}
\newcommand{\assign}{:=}
\usepackage[hang,small,bf]{caption}
\begin{document}
\begin{figure}[!h]
\centering
\begin{tikzpicture}[shorten >=1pt,node distance=3cm,on grid,auto]
\tikzstyle{state}=[shape=circle,thick,draw,minimum size=1.5cm]
\node[state] (A1) {$A_1$};
\node[state,above of=A1] (B1) {$B_1$};
\node[state,above of=B1] (C1) {$C_1$};
\node[state,right of=A1] (A2) {$A_2$};
\node[state,above of=A2] (B2) {$B_2$};
\node[state,above of=B2] (C2) {$C_2$};
\path[->,draw,thick]
(A1) edge node {$l_A$} (B2)
(B1) edge node {$l_B$} (B2)
;
\end{tikzpicture}
\caption{Model}
\label{fig:f1}
\end{figure}
\end{document}
Run Code Online (Sandbox Code Playgroud)
有人可以告诉我如何才能达到这种效果吗?
谢谢!