Answer the question
In order to leave comments, you need to log in
Is it possible to do interpolation in the scatter method?
There is a list of temperatures that are visualized in polar coordinates, the color corresponds to the temperature value. You need to do interpolation so that intermediate color values between points are calculated.
Can this be done with the scatter method?
Or how to implement using the imshow method? Replace points with another geometry object?
import matplotlib.pyplot as plt
from matplotlib import cm
import numpy as np
#температурные значения
data = [36.1, 33.2, 34.6, 35.3, 34.1, 32.9, 35.6, 36.7]
#количество точек
N = 8.
#координаты
r = [1, 1, 1, 1, 1, 1, 1, 1]
theta = [0, 0.78, 1.58, 2.36, 3.15, 3.94, 4.73, 5.5]
area = 800
colors = ["#1f3a93", "#55bed7", "#75af1c", "#fce032", "#e73e33"]
fig = plt.figure()
ax = fig.add_subplot( projection='polar')
i = 0
# вызываем рисование графика
c = ax.scatter(theta, r,
# цвет присваиваем в зависимости от значения data[i] c = [colors[индекс] по условию плюс цикл по data]
c = [colors[0] if a < 31.0 else colors[1] if 32.5 <= a < 34.5 else colors[2] if 34.5 <= a < 35.5 else colors[3] if 35.5 <= a < 36.5 else colors[4] for a in data ], s=area, cmap='hsv', alpha=1)
Answer the question
In order to leave comments, you need to log in
Specify your wishlist.
There are temperatures. Clear. They match the colors. There is already a question. Colors, those that are colors - are they hard-coded for you or did you set them yourself?
"Interpolation with intermediate color values between points" is not clear at all.
Since you have colors set - actually in 3D RGB space - for what "intermediate points" do you want to interpolate?
If I understand the task correctly, then you actually need to interpolate temperatures at intermediate points, and already represent their values in the appropriate color. But then the temperature colors must be set not from the lamp, but according to some algorithm. Well, for example, like this:
data = [36.1, 33.2, 34.6, 35.3, 34.1, 32.9, 35.6, 36.7]
rgb = [int(i*10) for i in data]
c = ax.scatter(theta, r,
c = rgb,
s=area, cmap='hsv', alpha=1)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question