我有以下代码:
\documentclass[12pt,a4paper]{article}
\newcounter{conto}
\setcounter{conto}{\time}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{ dsfont }
\usepackage[mathscr]{euscript}
\newcommand{\longto}{\longrightarrow}
\usepackage[a4paper,top=1cm,bottom=2cm,left=1cm,right=1cm]{geometry}
\usepackage{mathrsfs}
\usepackage{amsmath}
\pagestyle{empty}
\usepackage{pgfplots}
\usepackage{eurosym}
\begin{document}
$$\begin{tikzpicture}
\begin{axis}[
xmax=10.5, xmin=-5.5,
ymax=7.8, ymin=0,
axis x line=bottom,
axis y line=left,
axis x line=middle,
axis y line=middle,
title=AABBCCDDEEFFGGHHIIJJKKLLMM,
xlabel={\(a \in \{t_s\}_{s=1}^6\)},
ylabel={\(\mathfrak{f}_{a}\)},
every axis x label/.style={
at={(ticklabel* cs:1.05)},
anchor=west,},
every axis y label/.style={
at={(ticklabel* cs:1.05)},
anchor=south,},
xtick={-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9},
ytick={0,1,2,3,4,5,6,7},
]
\addplot+[ycomb] plot coordinates
{(-4,2) (-2,6) (1,3) (2,5) (8,3) (9,7)};
\end{axis}
\end{tikzpicture}$$
\end{document}
输出为:
我有以下内容问题:
ylabel
已覆盖!- x 轴上没有零点!
- 图形上 x 轴的测量单位和 y 轴的测量单位不同!
我该如何解决这些问题?
提前致谢!
答案1
这是一次尝试,因为我使用了所需的最低包,所以ylabel
进行了更改。mathbf
A1:更改 cs:xx 的参数
every axis y label/.style={at={(ticklabel* cs:1.2)}
A2:使用
axis x line=bottom,
axis y line=left,
或者代替axis lines=middle
,假设会发生交集。要获取 xtick 标签 0,请使用以下命令。(另请参见第二张图片)
axis y line=middle,
axis x line=bottom,
A3:使用
axis equal image=true,
代码
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
xmax=10.5, xmin=-5.5,
ymax=7.8, ymin=0,
axis x line=bottom,
axis y line=left,
axis equal image=true,
% axis x line=middle,
% axis y line=middle,
title=AABBCCDDEEFFGGHHIIJJKKLLMM,
xlabel={\(a \in \{t_s\}_{s=1}^6\)},
ylabel={\(\mathbf{f}_{a}\)},
every axis x label/.style={
at={(ticklabel* cs:1.05)},
anchor=west,},
every axis y label/.style={
at={(ticklabel* cs:1.2)},
anchor=south,},
xtick={-4,-3,-2,-1,0,1,2,3,4,5,6,7,8,9},
ytick={0,1,2,3,4,5,6,7},
]
\addplot+[ycomb] plot coordinates
{(-4,2) (-2,6) (1,3) (2,5) (8,3) (9,7)};
\end{axis}
\end{tikzpicture}
\end{document}