My goal is to create a half color wheel in tikz looking something like that:
The code I used to produce the above picture is based on:
\shade[shading=color wheel white center,opacity=.3] [even odd rule]
(1,0) arc (0:360:1);
However there are multiple problems:
- first, it is not a half wheel but a full wheel that I "cut" while taking the screenshot. If I replace
(0:360)
with(0:180)
, the center of the shading (see the white part) is not at the right position: - secondly, even if I find how to "recenter" the shading (if you know how to do that I'm still interested), the colors are still not going from the whole spectre: for instance cyan is not visible since only half of the spectre will be visible.
- lastly, it is not easily customizable if I want other shapes/functions/colors.
Do you know a way to do this half color wheel? I'd love to be able to provide directly a "function" taking the coordinates (absolute and relative, in cartesian and polar form for instance) as input and outputting the final color (in that case the hue would be the polar angle divided by 2, the luminosity would be a function of the radius), but can't find a nice way to do that. Note also that I'll later want to find a way to rotate the final shape, in my case to fill the lower part of the circle with the rotated color wheel.
-- EDIT --
Using clipping
as proposed in comment, together with shading angle=180
(rotating the scope directly does not work with shading...) I was able to achieve a first nice version (it works mostly because the center of the shading has the good position before clipping):
However, it does not contain all the colors I want since the spectrum is cut in two. Any idea how I could solve that with a more customizable function? Maybe by inserting pgfplots inside tikzpicture
? (No idea if it is possible)
Also, shading seems to fail to render into Firefox (which is quite bad for my application...) so I'd love a more universal solution:
In firefox:
MWE
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{tikz}
\usetikzlibrary{positioning,arrows,calc,math,angles,quotes,shadings}
\usepackage{blochsphere}
\usepackage{braket}
\begin{document}
\begin{tikzpicture}[
scale=1.5
]
\def\maxim{1.5}
\draw[help lines,opacity=.5] (-1.5,-1.5) grid[step=0.25] (1.5,1.5);
\begin{scope}
\clip (-1,0) rectangle (1,1);
\shade[shading=color wheel white center,opacity=.3] [even odd rule]
(1,0) arc (0:360:1);
\end{scope}
\begin{scope}
\clip (-1,-1) rectangle (1,0);
\shade[shading=color wheel white center,opacity=.3,shading angle=180] [even odd rule]
(1,0) arc (0:360:1);
\end{scope}
\draw[-] (-\maxim,0) -- (\maxim,0);
\draw[-] (0,-\maxim) -- (0,\maxim);
\draw (0,0) circle (1);
\draw[-latex] (0,0) -- (0:1) coordinate (ket0) node[above right] {$\ket{0}$};
\draw[-latex] (0,0) -- (90:1) coordinate (ket1) node[above right] {$\ket{1}$};
\draw[-latex] (0,0) -- (45:1) node[above right] (ketp) {$\ket{+}$};
\draw[-latex] (0,0) -- (90+45:1) node[above left] (ketm) {$\ket{-}$};
\coordinate (orig) at (0,0);
\pic[draw,red,thick,angle radius=10.7]{right angle=ket0--orig--ket1};
\draw[-latex] (0,0) -- (180+0:1) coordinate (ket0) node[below left] {$\ket{0}$};
\draw[-latex] (0,0) -- (180+90:1) coordinate (ket1) node[below left] {$\ket{1}$};
\draw[-latex] (0,0) -- (180+45:1) node[below left] (ketp) {$\ket{+}$};
\draw[-latex] (0,0) -- (180+90+45:1) node[below right] (ketm) {$\ket{-}$};
\end{tikzpicture}
\end{document}
\clip (-1.1,0) rectangle (1.1,1.1);
before the wheel. You probably will need a scope too.