我尝试在新计算机上读取 csv 文件(所以我第一次在这台计算机上使用 Spyder):
import pandas as pd
path = "D:/"
test = pd.read_csv(path+"test.csv")
Run Code Online (Sandbox Code Playgroud)
我成功地在我以前的计算机上读取了这个文件。
但在这里,我得到这个错误:
TypeError: descriptor 'axes' for 'BlockManager' objects doesn't apply to 'SingleBlockManager' object
Run Code Online (Sandbox Code Playgroud)
有谁知道发生了什么事?
我正在尝试在我的绘图上添加markeredgecolor(marker='.',并且我希望标记根据其特征被不同的颜色包围)。
我尝试对地理数据执行此操作:https ://python-graph-gallery.com/131-custom-a-matplotlib-scatterplot/
fig, ax = plt.subplots(figsize = (8,6))
df.plot(ax=ax,color='green', marker=".", markersize=250)
df2.plot(ax=ax,color='green', marker=".", markerfacecolor="orange", markersize=250)
Run Code Online (Sandbox Code Playgroud)
但是我收到这个错误:
AttributeError: 'PathCollection' object has no property 'markeredgecolor'
Run Code Online (Sandbox Code Playgroud)
您知道问题是什么以及该怎么办吗?
编辑 - 使用可重现的示例:
#Packages needed
import pandas as pd
import matplotlib.pyplot as plt
import geopandas as gpd
import shapely.wkt
#Creating GeoDataFrame df2
df2 = pd.DataFrame([shapely.wkt.loads('POINT (7.23173 43.68249)'),shapely.wkt.loads('POINT (7.23091 43.68147)')])
df2.columns=['geometry']
df2 = gpd.GeoDataFrame(df2)
df2.crs = {'init' :'epsg:4326'}
#Ploting df2
fig, ax = plt.subplots()
df2.plot(ax=ax,color='green', marker=".", markerfacecolor="orange")
Run Code Online (Sandbox Code Playgroud) 我想创建这样的卫星地图:https ://plotly.com/python/mapbox-layers/
我尝试用我的数据(来自法国)重现此代码:
import pandas as pd
us_cities = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/us-cities-top-1k.csv")
import plotly.express as px
fig = px.scatter_mapbox(us_cities, lat="lat", lon="lon", hover_name="City", hover_data=["State", "Population"],
color_discrete_sequence=["fuchsia"], zoom=3, height=300)
fig.update_layout(
mapbox_style="white-bg",
mapbox_layers=[
{
"below": 'traces',
"sourcetype": "raster",
"sourceattribution": "United States Geological Survey",
"source": [
"https://basemap.nationalmap.gov/arcgis/rest/services/USGSImageryOnly/MapServer/tile/{z}/{y}/{x}"
]
}
])
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
Run Code Online (Sandbox Code Playgroud)
但我无法按我想要的方式缩放。
我如何选择底图以获得数据区域的良好分辨率?您是否知道一组底图,我可以从中选择一张以法国为中心的底图?