I want to draw the rhombus $|x|+|y|=\sqrt{2}$ using tikz or pgfplot, but I am unable to do that.

I want to draw it, but despite several attempts, I am nowhere.

  • 1
    For what purpose do you want to draw it? Just for the shape (this ca be achieved with a simple rotated square) or to use it in a function problem?
    – SebGlav
    Jul 11 at 12:49
  • 2
    Remember to alway show your attempts when asking a question. It tells us valuable information about what it is going to be used for and the expected result. -also this site is about conceptual problems -not about doing others work. Jul 11 at 14:42
  • Sure. By the way, why was I unable to write my question in proper LaTeX?
    – Ashiq
    Jul 11 at 14:47
  • My understanding is that tex.stackexchange.com is special regarding LaTeX code. Here people often needs to show code, so the site does not render it. -also people here know what the code means, so no need to render it. Jul 11 at 15:21
  • Regarding why LaTeX output isn't shown, see How do I get latex output to show up on tex.SE? (read the comments). Jul 11 at 15:42
\begin{axis}[axis equal]
  \addplot [domain=-sqrt(2):sqrt(2), samples=3]{abs(x)-sqrt(2)};
  \addplot [domain=-sqrt(2):sqrt(2), samples=3]{-abs(x)+sqrt(2)};

Rhombus graph

  • It cannot be improved. Jul 11 at 13:02
  • Thanks a lot. How can I fill this rhombus green?
    – Ashiq
    Jul 11 at 14:31
  • @FirdousAhmadMala: \fill[green] ({-sqrt(2)},0) -- (0,{sqrt(2)}) -- ({sqrt(2)},0) -- (0,{-sqrt(2)}) -- cycle; Jul 11 at 14:38

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.