[Matplotlib-users] Changing the colorbar / Absolute marker size

Thank you to all, and my deepest apologies to have not found related topics in archive and through googling.

I have an Earth map with markers on it. Each marker has 4 attributes: longitude, latitude, temperature and size.

In the example, positions are random.

The colorbar range is set to temperature range.

When I zoom in the map, I would like to:

···

http://www.spacebel.be/wp-content/uploads/2011/06/image-sign-sbp.jpg

Guy Léonis

Project Manager

Ildefons Vandammestraat, 5-7 Bat B 1st floor - Hoeilaart Office Center - B-1560 HOEILAART

Tel: +32 (0) 2 658 20 11 - Fax: +32 (0) 2 658 20 90

www.spacebel.be

Import python standard libraries

import os

import sys

Import specific libraries

import netCDF4

import matplotlib

#matplotlib.use(‘Qt4Agg’)

import matplotlib.pyplot as plt

import numpy as np

pat_version = “2”

window_id = 1

channel = 1

sample = 1

extra = “user string”

window_title = "MWS - PAT - V%s - %d - Map of channel %02d / sample %02d - %s " \

% (pat_version, window_id, channel, sample, extra)

lon = np.random.random(50) * 360 - 180

lat = np.random.random(50) * 180 - 90

bt = np.random.random(50) * 50 + 250

radius = np.random.random(50)

(fig, ax) = plt.subplots()

sc = None

cm = plt.get_cmap(“rainbow”)

def on_draw(event):

global sc

print("\n\nDraw event")

print(ax.get_xlim())

print(ax.get_ylim())

(x_min, x_max) = ax.get_xlim()

(y_min, y_max) = ax.get_ylim()

x =

y =

z =

for (lx, ly, lz) in zip(lon, lat, bt):

if (x_min < lx < x_max) and (y_min < ly < y_max):

x.append(lx)

y.append(ly)

z.append(lz)

if sc is not None:

print((len(z), min(z), max(z)))

sc.set_offsets(np.c_[x, y])

fig.canvas.draw_idle()

plt.pause(0.1)

#sc.remove()

#sc = plt.scatter(x, y, s=50, c=z, marker=‘o’, cmap=cm, vmin=int(min(z)) , vmax=int(max(z)) + 1)

#fig.canvas.draw()

draw_event_cb_id = fig.canvas.mpl_connect(“draw_event”, on_draw)

fig.set_dpi(100)

fig.set_size_inches(8, 4.44, forward=True)

fig.suptitle(“Brightness Temperature”)

plt.subplots_adjust(left=0.05, right=0.90, bottom=0.05, top=0.90)

plt.xlim(-180.0, 180.0)

plt.ylim(-90.0, 90.0)

man = plt.get_current_fig_manager()

man.canvas.set_window_title(window_title)

world_path = os.getenv(“MWS_HOME_PAT”) + “/tools/PAT/data/world/world_010m.txt”

fp = open(world_path)

world_lines = fp.readlines()

fp.close()

data_x =

data_y =

for line in world_lines:

if len(line) == 1:

if len(data_x) > 0:

plt.plot(data_x, data_y, marker="", color=“black”, markersize=0, linewidth=1)

data_x =

data_y =

else:

x, y = line.split()

data_x.append(float(x))

data_y.append(float(y))

#plt.imshow(lon, lat, bt, cmap=plt.get_cmap(“rainbow”))

sc = plt.scatter(lon, lat, s=50, c=bt, marker=‘o’, cmap=cm, vmin=int(min(bt)), vmax=int(max(bt)) + 1)

cax = plt.axes([0.91, 0.05, 0.02, 0.9])

plt.colorbar(cax=cax)

plt.show()