
我正在與 tikzpicture 合作繪製一些數據點。我試圖將數據點的填充顏色設定為預設藍色以外的其他顏色,但我不知道我做錯了什麼。我確信我過去只是通過更改值來更改顏色fill
,但在這種情況下不起作用
我附上了 MWE - 有人可以幫我嗎:
\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{times}
\usepackage{url}
\usepackage{latexsym}
\usepackage{booktabs}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{graphicx, subcaption}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{pgfplots, pgfplotstable}
\usepackage{caption}
\usepackage{rotating}
\usepackage{nicefrac}
\usepackage{subfig}
\usetikzlibrary{spy}
\usepackage{color,colortbl}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}
\begin{semilogyaxis}[
nodes near coords,
ylabel={time [s]},
enlargelimits=0.2,
log basis y=10,
]
\addplot+[
black,
fill=red,
only marks,
point meta=explicit symbolic,
visualization depends on=\thisrow{alignment} \as \alignment,
every node near coord/.append style={font=\tiny,anchor=\alignment}
]
table [
meta index=2
]{
x y label alignment
0.4 7.24 C-1 0
0.5 4.42 C-2 0
};
\end{semilogyaxis}
\end{tikzpicture}
\caption{Text}
\label{fig:a1}
\end{figure*}
\end{document}
答案1
您需要設定mark options
整個軸的選項而不是選項。您也不需要同時載入pgfplots
和,並且您應該使用該選項pgfplotstable
來設定您的相容版本。您還加載了兩次。以後請嘗試生成pgfplots
compat
amsmath
最小的範例,刪除了重現問題所不需要的所有套件。
\documentclass[a4paper]{article}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.12}
\begin{document}
\begin{figure*}
\centering
\begin{tikzpicture}
\begin{semilogyaxis}[
nodes near coords,
ylabel={time [s]},
enlargelimits=0.2,
log basis y=10,
]
\addplot+[
black,
mark options={fill=red},
only marks,
point meta=explicit symbolic,
visualization depends on=\thisrow{alignment} \as \alignment,
every node near coord/.append style={font=\tiny,anchor=\alignment}
]
table [
meta index=2
]{
x y label alignment
0.4 7.24 C-1 0
0.5 4.42 C-2 0
};
\end{semilogyaxis}
\end{tikzpicture}
\caption{Text}
\label{fig:a1}
\end{figure*}
\end{document}