4

folks!

I want to draw a polygon with TikZ that has a color gradient from white to gray. Unfortunately, the polygon has a small gray border and I don't know why and how to remove it. This is my MWE:

\documentclass[tikz, border=10pt]{standalone}
\begin{document}

\tikz{\path[fill, left color=white, right color=black!10] (0, 0) -- (1, 1) -- (1, 3) -- (0, 4) -- cycle;}

\end{document}

This is the result:

MWE

You can see the border which seems to be in the color black!10 (notably the left, top and bottom border). If I set the color of the border explicitly to white (draw=white) it looks fine but only on white background (of course). In my image, the left part of the polygon is on a white background the right part of a gray (black!10) background. Thus, a white border is not the solution that works for me.

So, the question is: How can I remove the border? (And: What is the reason that the border even exists?) Or, in case it is not possible: How can I set the left border to white and the right border to black!10?

Thanks for your help in advance.

Cornelius

  • As you accepted the answer, you can also upvote it. – Tarass Mar 17 '18 at 13:03
  • @Tarass: I actually did this already. Due to the lack of reputation it is recorded but not publicity displayed, StackExchange said. Anyway, thanks for your suggestion. – Cornelius Mar 17 '18 at 13:21
  • Sorry, I didn't notice that. Welcome to Latex.SX ! – Tarass Mar 17 '18 at 13:26
5

What you see is not a "real" border but rather a filled area, that is additionally shaded. Replace fill by shade to only shade it.

| improve this answer | |
  • That's it! Easy like that! It even works if I remove fill at all. – Cornelius Mar 17 '18 at 12:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.