我已尽最大努力检查但未找到任何允许您在kwds
散点图上绘制线条(例如y=a-x
)的pandas
(不一定是最合适的线)并将它带到后面(或前面)。
#the data frame
ax=df.plot(kind='scatter', x='myX', y='myY',title="Nice title",
xlim=[0,100],ylim=[0,100],figsize=(8,5), grid=True,fontsize=10)
#the line
lnsp=range(0,110,10)
line=[100-i for i in lnsp] #line is y=100-x
ax=line_df.plot(kind='line',color='r',ax=ax,legend=False,grid=True,linewidth=3)
有什么我可以使用的吗?或者它只是绘制两件事的顺序?
答案 0 :(得分:3)
您需要定义一个轴,然后将pandas图传递给该轴。然后,您可以将任何行绘制到先前定义的轴上。这是一个解决方案。
/* Vars */
const center = ol.proj.transform([1.44, 43.603], "EPSG:4326", "EPSG:3857")
const imgSize = [400, 267]
const imgExtent = [center[0], center[1], center[0] + imgSize[0], center[1] + imgSize[1]]
let rotation = 45
/* Init map */
const map = new ol.Map({
target: 'map',
view: new ol.View({
zoom: 16,
center,
}),
layers: [
// Map tiles layer
new ol.layer.Tile({
source: new ol.source.OSM()
}),
// Feature layer
new ol.layer.Vector({
source: new ol.source.Vector({
features: [
new ol.Feature({
geometry: new ol.geom.Point(center),
}),
],
}),
}),
],
})
/* Init image layer */
const imgLayer = new ol.layer.Image({
opacity: 0.7,
source: new ol.source.ImageStatic({
url: "https://pbs.twimg.com/profile_images/685220121598660608/2uZUdcS1.jpg",
imageExtent: imgExtent,
})
})
imgLayer.on("precompose", evt => {
const pixel = map.getPixelFromCoordinate(center)
const ctx = evt.context
ctx.save()
ctx.translate(pixel[0], pixel[1])
ctx.rotate(rotation * Math.PI / 180)
ctx.translate(-pixel[0], -pixel[1])
})
imgLayer.on("postcompose", evt => {
const ctx = evt.context
ctx.restore()
})
map.addLayer(imgLayer)