TikZ 网格质量低

TikZ 网格质量低

当我在 TikZ 中使用网格创建旋转的 3D 坐标系时,它看起来有点糟糕且像素化。倾斜的 x 轴看起来很好,所以这不是由于旋转造成的。我还改变了线条粗细,但没有效果。

在此处输入图片描述

即使在 PDF 上非常近距离缩放,阶梯效果仍然存在。

在此处输入图片描述

梅威瑟:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[usenames, dvipsnames]{xcolor}
    \definecolor{mgelb}{RGB}{255, 187, 0}
    \definecolor{mblau}{RGB}{10, 59, 104}
    \definecolor{mturkis}{RGB}{0, 171, 183}
    \definecolor{mgrau1}{RGB}{230, 230, 230}
    \definecolor{mgrau3}{RGB}{153, 153, 153}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{75}{15}
\begin{tikzpicture}[scale=9 ,thick, tdplot_main_coords, grid/.style={very thin,mgrau3}]
    \foreach \x in {0,0.2,...,1}
    \foreach \y in {0,0.2,...,1}
    {
        \draw[grid] (\x,0) -- (\x,1);
        \draw[grid] (-0,\y) -- (1,\y);
    }
    \draw[->,mgelb](0,0,0) -- (1,0,0)
        node[right]{$x$}
        node[midway, below, sloped](TextNode){Beschichtungsrichtung};
    \draw[->,mblau](0,0,0) -- (0,1,0)
        node[left]{$y$};
    \draw[->,mturkis](0,0,0) -- (0,0,0.8)
        node[right]{$z$}
        node[midway, above, sloped](TextNode){Baurichtung};
    \shade[ball color = mgrau1] (0.5,0.5,0.25) circle (0.25cm);
    \draw[thin] (0.5,0.5,0.25) circle (0.25cm);
\end{tikzpicture}

\end{document}

答案1

在 xy 平面上画一个真实网格怎么样?这解决了这个问题。为什么?见下文。

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[usenames, dvipsnames]{xcolor}
    \definecolor{mgelb}{RGB}{255, 187, 0}
    \definecolor{mblau}{RGB}{10, 59, 104}
    \definecolor{mturkis}{RGB}{0, 171, 183}
    \definecolor{mgrau1}{RGB}{230, 230, 230}
    \definecolor{mgrau3}{RGB}{153, 153, 153}
\usepackage{tikz}
\usepackage{tikz-3dplot}

\begin{document}

\tdplotsetmaincoords{75}{15}
\begin{tikzpicture}[scale=9 ,thick, tdplot_main_coords, grid/.style={very thin,mgrau3}]
    \begin{scope}[canvas is xy plane at z=0]
     \draw[grid] (0,0) grid[step=0.2] (1,1);
    \end{scope}
    \draw[->,mgelb](0,0,0) -- (1,0,0)
        node[right]{$x$}
        node[midway, below, sloped](TextNode){Beschichtungsrichtung};
    \draw[->,mblau](0,0,0) -- (0,1,0)
        node[left]{$y$};
    \draw[->,mturkis](0,0,0) -- (0,0,0.8)
        node[right]{$z$}
        node[midway, above, sloped](TextNode){Baurichtung};
    \shade[ball color = mgrau1] (0.5,0.5,0.25) circle (0.25cm);
    \draw[thin] (0.5,0.5,0.25) circle (0.25cm);
\end{tikzpicture}

\end{document}

在此处输入图片描述

你的方法有什么问题?由于你嵌套了循环,所以每条网格线绘制了 6 次。如果你只使用一次循环,即精确绘制每条网格线一次,问题就会(几乎)完全消失。

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[usenames, dvipsnames]{xcolor}
    \definecolor{mgelb}{RGB}{255, 187, 0}
    \definecolor{mblau}{RGB}{10, 59, 104}
    \definecolor{mturkis}{RGB}{0, 171, 183}
    \definecolor{mgrau1}{RGB}{230, 230, 230}
    \definecolor{mgrau3}{RGB}{153, 153, 153}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\begin{document}

\tdplotsetmaincoords{75}{15}
\begin{tikzpicture}[scale=9 ,thick, tdplot_main_coords, grid/.style={very
thin,mgrau3}]
    \foreach \x in {0,0.2,...,1}
    {
        \draw[grid] (\x,0) -- (\x,1);
    }
    {\foreach \y in {0,0.2,...,1}        
        \draw[grid] (-0,\y) -- (1,\y);
    }
    \draw[->,mgelb](0,0,0) -- (1,0,0)
        node[right]{$x$}
        node[midway, below, sloped](TextNode){Beschichtungsrichtung};
    \draw[->,mblau](0,0,0) -- (0,1,0)
        node[left]{$y$};
    \draw[->,mturkis](0,0,0) -- (0,0,0.8)
        node[right]{$z$}
        node[midway, above, sloped](TextNode){Baurichtung};
    \shade[ball color = mgrau1] (0.5,0.5,0.25) circle (0.25cm);
    \draw[thin] (0.5,0.5,0.25) circle (0.25cm);
\end{tikzpicture}

\end{document}

在此处输入图片描述

不用说,你可以将循环重写为

\foreach \x in {0,0.2,...,1}
{
    \draw[grid] (\x,0) -- (\x,1);
    \draw[grid] (-0,\x) -- (1,\x);
}

相关内容