下图显示了我的问题:我想跳过 x_2 轴上的“2”。我该怎么做?
相应的代码如下:
\documentclass[11pt,a4paper]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\pgfdeclarepatternformonly{myDots}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{1pt}{1pt}}{\pgfqpoint{10pt}{10pt}}%
{
\pgfpathcircle{\pgfqpoint{0pt}{0pt}}{.5pt}
\pgfusepath{fill}
}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-2,xmax=4,ymin=0,ymax=5]
\tkzAxeX[label=$x_1$]
\tkzAxeY[label=$x_2$,orig=false]
% points
\tkzDefPoint(0,0){x1}
\tkzDefPoint(0,3){x2}
\tkzDefPoint(3,3){x3}
\tkzDefPoint(2,0){x4}
{
\tkzSetUpPoint[size=10,fill=black]
\tkzDrawPoints(x1,x2,x3,x4)
}
% decision space
\tkzDrawSegments(x2,x3 x4,x3)
\tkzFillPolygon[pattern=myDots](x1,x2,x3,x4)
\tkzDefPoint(1.,1.75){X}
\tkzLabelPoint(X){$\mathcal{X}$}
% D-set
\tkzDefPoint(0,1.75){p1}
\tkzLabelPoint[right](p1){$x'$}
\tkzDefPoint(-1.5,2.25){p2}
\tkzDefPoint(-0.75,3.75){p3}
\tkzDrawSegments(p2,p1 p1,p3)
\tkzDefPoint(-1,3){d1}
\tkzLabelPoint[left](d1){$\mathcal{D}_{x'}$}
\tkzFillPolygon[pattern=dots](p1,p2,p3)
\end{tikzpicture}
\end{document}
先感谢您!
答案1
这是一个解决方案,使用\tkzDrawY
和\tkzLabelPoint
命令。
笔记可以使用\tkzDefPoint
\documentclass[11pt,a4paper]{article}
\usepackage{tkz-euclide}
\usetkzobj{all}
\pgfdeclarepatternformonly{myDots}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{1pt}{1pt}}{\pgfqpoint{10pt}{10pt}}%
{
\pgfpathcircle{\pgfqpoint{0pt}{0pt}}{.5pt}
\pgfusepath{fill}
}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmin=-2,xmax=4,ymin=0,ymax=5]
\tkzAxeX[label=$x_1$]
\tkzDrawY[label=$x_2$]
\foreach \y in {1,...,5} {%
\ifnum \y=2
%\tkzLabelPoint[right=1pt](0,\y){\y}
\else
\tkzLabelPoint[left=1pt](0,\y){\y}
\fi}
% points
\tkzDefPoint(0,0){x1}
\tkzDefPoint(0,3){x2}
\tkzDefPoint(3,3){x3}
\tkzDefPoint(2,0){x4}
{
\tkzSetUpPoint[size=10,fill=black]
\tkzDrawPoints(x1,x2,x3,x4)
}
% decision space
\tkzDrawSegments(x2,x3 x4,x3)
\tkzFillPolygon[pattern=myDots](x1,x2,x3,x4)
\tkzDefPoint(1.,1.75){X}
\tkzLabelPoint(X){$\mathcal{X}$}
% D-set
\tkzDefPoint(0,1.75){p1}
\tkzLabelPoint[right](p1){$x'$}
\tkzDefPoint(-1.5,2.25){p2}
\tkzDefPoint(-0.75,3.75){p3}
\tkzDrawSegments(p2,p1 p1,p3)
\tkzDefPoint(-1,3){d1}
\tkzLabelPoint[left](d1){$\mathcal{D}_{x'}$}
\tkzFillPolygon[pattern=dots](p1,p2,p3)
\end{tikzpicture}
\end{document}