我正在尝试在地图上绘制lat和long事件数据。
在这段代码中,我需要十种不同的颜色参数才能使它工作,我的颜色已经用完了。 我该如何解决这个问题?
lon=[]
lat=[]
def getcolor(c):
if c in [1970,1980,1990,2000,2010]:
return 'bo'
if c in [1971,1981,1991,2001,2011]:
return 'go'
if c in [1972,1982,1992,2002,2012]:
return 'ro'
if c in [1973,1983,1993,2003,2013]:
return 'co'
if c in [1974,1984,1994,2004,2014]:
return 'mo'
if c in [1975,1985,1995,2005,2015]:
return 'yo'
if c in [1976,1986,1996,2006,2016]:
return 'ko'
else :
return 'wo' # I have run out of color arguments
def map_year(year):
count=year
while count>year-10:
lon=pd.Series(df.longitude[df['iyear']==count])
lat=pd.Series(df.latitude[df['iyear']==count])
x,y = map(lon.tolist(),lat.tolist())
map.plot(x, y, getcolor(count), markersize=6)
plt.hold(True)
count=count-1
plt.show()
map_year(2016)
更新 感谢您的投入.. 现在我在getcolor函数中将颜色格式更改为rgb元组,并将plot命令编辑为:
map.plot(x,y,color = getcolor(count),markersize = 6)
输出是 current ouput
十种不同颜色标记的所需输出是 desired output
请咨询
答案 0 :(得分:0)
您可以使用xamarin
关键字参数的任何颜色,例如十六进制RGB字符串,如async void OnLoginButtonClick(object sender, EventArgs e)
{
if (usernameEntry.Text != "" && passwordEntry.Text != "")
{
var response = GetLoginDetails(usernameEntry.Text,passwordEntry.Text);
var getData = await getDataFromService(usernameEntry.Text, passwordEntry.Text);
}
}
public static async Task<HttpResponseMessage> GetLoginDetails(string username, string password)
{
try
{
var httpClient = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "http://mywebserverIP/api/Users?Username=" + username + "&Password=" + password);
var response = await httpClient.SendAsync(request);
return response;
}
catch (Exception ex)
{
throw;
}
}
public static async Task<dynamic> getDataFromService(string username, string password)
{
using (var client = new HttpClient())
{
var responseText = await client.GetStringAsync("http://mywebserverIP/api/Users?Username=" + username + "&Password=" + password);
dynamic data = JsonConvert.DeserializeObject(responseText);
return data;
}
}
。
有关详细信息,请参阅Matplotlib文档:Matplotlib Colors