Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于pgfplot绘制直方图的一个问题 #255

Open
chenxiao445566 opened this issue Jun 27, 2022 · 4 comments
Open

关于pgfplot绘制直方图的一个问题 #255

chenxiao445566 opened this issue Jun 27, 2022 · 4 comments

Comments

@chenxiao445566
Copy link

\documentclass[border=3mm,tikz]{standalone}
\usepackage{pgfplots}
 \pgfplotsset{compat=1.18,
 	zhifangtu/.style={
 	axis lines =left,
 	tick align=inside,
 	yticklabel style={/pgf/number format/.cd,
 		fixed,
 		fixed zerofill,
 		precision=3},
 	area style,
 	x=0.2cm,
 	y=300cm,
 	ymin=0, ymax=0.1,
 	xmin=0, xmax=95,
 	xtick={0,10,20,30,40,50,60,70,80,90},
 	ytick={0.001,0.002,0.006,0.012,0.017,0.020,0.023},
 }
 }
\begin{document}
	\begin{tikzpicture}
		\begin{axis}[zhifangtu]
			\addplot+[ybar interval,fill=white,draw=black] plot coordinates {
				  (0, 0.001)
				  (10, 0.002) 
				  (20, 0.012) 
				  (30, 0.017) 
				  (40, 0.023) 
				  (50, 0.020)
				  (60, 0.017)
				  (70, 0.006)
				  (80, 0.002)
				  (90, 0)
			   };
		\end{axis}
	\end{tikzpicture}
\end{document}

我需要把ymax设置为0.028,但是无法编译(如果设置为0.1,又是可以编译的),然后找到原因是

yticklabel style={/pgf/number format/.cd,
 		fixed,
 		fixed zerofill,
 		precision=3},

把这段删掉,ymax=0.028是可以编译了,但我需要标签为小数,这段代码又不能删,那进一步还需如何设置?

@muzimuzhi
Copy link
Collaborator

不要在 /.style 里用 /.cd 切换 default path。pgfplots 的文档里也有这种用法,这是不够安全的。

    yticklabel style={
      /pgf/number format/fixed,
      /pgf/number format/fixed zerofill,
      /pgf/number format/precision=3
    },

非要切换 default path,需要再切回来

    yticklabel style={/pgf/number format/.cd,
      fixed,
      fixed zerofill,
      precision=3,
      /pgfplots/.cd
    },

不要只说「xxx,但是无法编译」,要提供具体的(第一处)报错信息。

@chenxiao445566
Copy link
Author

我用了最新的texstudio编译,假如有错误,它不报错了,那个红色的按钮一直红色(一直在编译),搞不懂!

@SwitWu
Copy link

SwitWu commented Jun 27, 2022

我用了最新的texstudio编译,假如有错误,它不报错了,那个红色的按钮一直红色(一直在编译),搞不懂!

建议使用命令行编译。

@muzimuzhi
Copy link
Collaborator

muzimuzhi commented Jun 27, 2022

我用了最新的texstudio编译,假如有错误,它不报错了,那个红色的按钮一直红色(一直在编译),搞不懂!

「假如有错误,它不报错了,……」这里我没理解。有问题,可以提供新的例子。

补充:编译停不下来,那按红色按钮停下来后,log 里有报错吗?有报错的话,提供例子 + 第一条报错信息。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants