我从NASA Earthdata网站(南美发生的火灾)中提取了一些火灾数据,并将这些数据绘制在了世界地图上。我使用了一个色条来显示每场火灾的亮度。
火的亮度方差不对应于整个色标范围,并且大多数火都具有相同的颜色(黄色)。这是我的代码:
import csv
from plotly.graph_objs import Scattergeo, Layout
from plotly import offline
filename = 'data/MODIS_C6_South_America_24h.csv'
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
print(header_row)
# Get latitudes, longitudes and brightness from this file.
lats, lons, brights = [], [], []
for row in reader:
lat = float(row[0])
lats.append(lat)
lon = float(row[1])
lons.append(lon)
bright = float(row[2])
brights.append(bright)
# Map the fires
data = [{
'type': 'scattergeo',
'lon': lons,
'lat': lats,
'marker': {
'size': [1/30* bright for bright in brights],
'color': brights,
'colorscale': 'Inferno',
'reversescale': True,
'colorbar': {'title': 'Brightness'},
},
}]
my_layout = Layout(title='South America Fires\npast 24 hours')
fig = {'data': data, 'layout': my_layout}
offline.plot(fig, filename='south_america_fires.html')
我可以以某种方式更改色标的限制,以使标记具有更宽的颜色范围并更好地区分吗?还是有更好的策略?
火的亮度变化与整个色阶范围
是的,他们愿意。只需看一下数据的简单可视化即可:
图1: Seaborn分布图
代码1: Seaborn分布图
import seaborn as sns
import numpy as np
sns.set(color_codes=True)
sns.distplot(tuple(brights))
您的情节最终看起来像它的样子,原因有三个:
brightness = 330
周围有许多个观察值>*图2:
brights
排序brights.sort()
我认为应该注意这一点:
[...]以便标记具有更宽的颜色范围并且更易于区分?因此,真的没有必要为此担心:
我能以某种方式更改色阶的限制[...]您
可以
也考虑对数据进行日志重新编码。我测试了它,但是并没有太大的视觉差异。并请注意,我删除了'size': [1/60* bright for bright in brights]
部分。我认为情节2看起来比这更好:
完整代码:
import csv
from plotly.graph_objs import Scattergeo, Layout
from plotly import offline
filename = 'C:\\pySO\\MODIS_C6_South_America_24h.csv'
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
print(header_row)
# Get latitudes, longitudes and brightness from this file.
lats, lons, brights = [], [], []
for row in reader:
lat = float(row[0])
lats.append(lat)
lon = float(row[1])
lons.append(lon)
bright = float(row[2])
brights.append(bright)
brights.sort()
# Map the fires
data = [{
'type': 'scattergeo',
'lon': lons,
'lat': lats,
'marker': {
#'size': [1/60* bright for bright in brights],
'color': brights,
#'color': brights.sort(),
'colorscale': 'Inferno',
'reversescale': True,
'colorbar': {'title': 'Brightness'},
},
}]
my_layout = Layout(title='South America Fires\npast 24 hours')
fig = {'data': data, 'layout': my_layout}
offline.plot(fig, filename='south_america_fires.html')