添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
想表白的四季豆  ·  Tonka Coders & Makers ...·  3 月前    · 
留胡子的水龙头  ·  [android] error: ...·  7 月前    · 
卖萌的枇杷  ·  Parsing JSON in Rust·  7 月前    · 
逼格高的路灯  ·  GitHub-Chinese-Top-Cha ...·  8 月前    · 

I’m a complete novice at plotly and would really appreciate if someone could point me to equivalents of plotting functions from matplotlib that would result in a plot displayed below. The plot shows heat interpolation between dots (sensors).

from scipy.interpolate.rbf import Rbf #Radial basis functions
from sqlalchemy import create_engine
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
im = plt.imread('C:\\Users\\definitely_not_me\\Downloads\\floor_plan.jpg')
# Create Figure and Axes objects
fig,ax = plt.subplots(1)
# Display the image on the Axes
implot = ax.imshow(im)
# Define location of "sensors" on the axes
x = [100, 100, 100, 250, 250, 250, 400, 400, 400]
y = [100, 350, 600, 100, 350, 600, 100, 350, 600]
z = [22, 23, 22, 22, 25, 15, 21, 22, 22] #temperature
rbf_adj = Rbf(x, y, z, function = 'gaussian')
# Set extent to which colour mesh stretches over
# the underlying image
x_fine = np.linspace(0, 1000, 81) #81 - num of samples
y_fine = np.linspace(0, 700, 82)
x_grid, y_grid = np.meshgrid(x_fine, y_fine)
z_grid = rbf_adj(x_grid.ravel(), y_grid.ravel()).reshape(x_grid.shape)
# plot the pcolor on the Axes. Use alpha to set the transparency
p=ax.pcolor(x_fine, y_fine, z_grid, alpha=0.3)
ax.invert_yaxis() #invert Y axis for X and Y to have same starting point
# Add a colorbar for the pcolor field
fig.colorbar(p,ax=ax)
plt.savefig('heatmap.png')

I know of these (1 and 2 )tutorials related to background images and interpolation in a 3d space but whenever I try to produce anything of real value I end up with some unintelligible mess. Thanks in advance!

Hello,
the heatmap tutorial should be of interest to you https://plot.ly/python/heatmaps/. If your image is single-channel (grayscale) you can plot it using a Heatmap. Otherwise, we have an Image trace and an imshow function which will be shipped with the next version of plotly.py next week.
You can also use a Heatmap for replacing matplotlib’s pcolor. For the interpolation, you should just keep on using scipy as you’re doing which is great. Otherwise you can make a contour plot from your data points, which will also perform interpolation. See for example https://plot.ly/python/contour-plots/