Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sequential color background
#1
What code do I use to change the color background of a radar chart.
I want to use a sequential color scheme from light blue to dark blue.
I assume that the starting point would be from matplotlib.pyplot using the cmaps.

Any help is appreciated.
Reply
#2
Here is an example where I would like to change the background.
# Plots a radar chart.

from math import pi
import matplotlib.pyplot as plt


# Set data
cat = ['Speed', 'Reliability', 'Comfort', 'Safety', 'Effieciency']
values = [90, 60, 65, 70, 40]

N = len(cat)

x_as = [n / float(N) * 2 * pi for n in range(N)]

# Because our chart will be circular we need to append a copy of the first 
# value of each list at the end of each list with data
values += values[:1]
x_as += x_as[:1]


# Set color of axes
plt.rc('axes', linewidth=0.5, edgecolor="#888888")


# Create polar plot
ax = plt.subplot(111, polar=True)


# Set clockwise rotation. That is:
ax.set_theta_offset(pi / 2)
ax.set_theta_direction(-1)


# Set position of y-labels
ax.set_rlabel_position(0)


# Set color and linestyle of grid
ax.xaxis.grid(True, color="#888888", linestyle='solid', linewidth=0.5)
ax.yaxis.grid(True, color="#888888", linestyle='solid', linewidth=0.5)


# Set number of radial axes and remove labels
plt.xticks(x_as[:-1], [])

# Set yticks
plt.yticks([20, 40, 60, 80, 100], ["20", "40", "60", "80", "100"])


# Plot data
ax.plot(x_as, values, linewidth=2, linestyle='solid', zorder=3)

# Fill area
ax.fill(x_as, values, 'b', alpha=0.0)


# Set axes limits
plt.ylim(0, 100)


# Draw ytick labels to make sure they fit properly
for i in range(N):
    angle_rad = i / float(N) * 2 * pi

    if angle_rad == 0:
        ha, distance_ax = "center", 10
    elif 0 < angle_rad < pi:
        ha, distance_ax = "left", 1
    elif angle_rad == pi:
        ha, distance_ax = "center", 1
    else:
        ha, distance_ax = "right", 1

    ax.text(angle_rad, 100 + distance_ax, cat[i], size=10, horizontalalignment=ha, verticalalignment="center")


# Show polar plot
plt.show()
Reply
#3
see: https://matplotlib.org/users/dflt_style_...color-maps

Also:
this may be indirectly linked to your request.
It may be of value since the code is presented, and you can see how background color was applied as a style:
https://matplotlib.org/gallery/style_she...background
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 902 Oct-25-2023, 09:09 AM
Last Post: codelab
  Sequential number for rows retrieved and storing the Primary UKey to the line number GYKR 2 555 Aug-22-2023, 10:14 AM
Last Post: GYKR
  Four sequential bytes; Need to remove high order bit in each to get correct output GrandSean 5 2,884 Feb-06-2021, 07:17 PM
Last Post: GrandSean
  Create a sequential number (counter) and reset at each duplicate Mekala 0 1,703 Sep-20-2020, 05:02 AM
Last Post: Mekala
  Use of input function to change screen background color in Turtles Oldman45 3 4,743 Jul-10-2020, 09:54 AM
Last Post: Oldman45
  Finding sequential invoice william888 0 1,341 Mar-24-2020, 12:41 AM
Last Post: william888
  How to obtain the background color of a cell using xlrd? Krszt 1 12,421 Mar-12-2019, 11:23 PM
Last Post: hshivaraj

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020