How set ticks invisible but leave tick-lables are visible
Question:
I plot a clock panel as:
import matplotlib.pyplot as plt
import numpy as np
# Create a polar coordinates
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, polar=True)
# set ticks and labels
angles = np.radians(np.linspace(0, 360, 12, endpoint=False))
labels = [str(l) for l in range(12)]
ax.set_xticks(angles, labels)
ax.set_yticks([])
It display as:
I want to set the ticks invisible but leave labels visible and tried adding line ax.set_xticks([])
Then all the ticks and tick-labels disappear.
How could I set ticks invisible but leave tick-labels visible?
Answers:
You can make your ticks transparent with ax.tick_params(grid_alpha=0)
:
import matplotlib.pyplot as plt
import numpy as np
# Create a polar coordinates
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, polar=True)
# set ticks and labels
angles = np.radians(np.linspace(0, 360, 12, endpoint=False))
labels = [str(l) for l in range(12)]
ax.set_xticks(angles, labels)
ax.tick_params(grid_alpha=0)
ax.set_yticks([])
plt.show()
Output:
Note: this also works with ax.tick_params(grid_linestyle='')
or ax.tick_params(grid_linewidth=0)
I plot a clock panel as:
import matplotlib.pyplot as plt
import numpy as np
# Create a polar coordinates
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, polar=True)
# set ticks and labels
angles = np.radians(np.linspace(0, 360, 12, endpoint=False))
labels = [str(l) for l in range(12)]
ax.set_xticks(angles, labels)
ax.set_yticks([])
It display as:
I want to set the ticks invisible but leave labels visible and tried adding line ax.set_xticks([])
Then all the ticks and tick-labels disappear.
How could I set ticks invisible but leave tick-labels visible?
You can make your ticks transparent with ax.tick_params(grid_alpha=0)
:
import matplotlib.pyplot as plt
import numpy as np
# Create a polar coordinates
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(111, polar=True)
# set ticks and labels
angles = np.radians(np.linspace(0, 360, 12, endpoint=False))
labels = [str(l) for l in range(12)]
ax.set_xticks(angles, labels)
ax.tick_params(grid_alpha=0)
ax.set_yticks([])
plt.show()
Output:
Note: this also works with ax.tick_params(grid_linestyle='')
or ax.tick_params(grid_linewidth=0)