I am wanting to recreate the following plot but with the size of the dots changing based on the magnitude (mag) value.
Here is my code so far:
data = load(filename) ; long = data(:,1) ; lati = data(:,2) ; year = data(:,3) ; mag = data(:,6) ; for i = 1:length(mag) if mag(i) < 3.0 mag(i) = NaN ; lati(i) = NaN ; long(i) = NaN ; endendnew_lati = zeros(length(lati),1) ;new_long = zeros(length(long),1) ;new_lati1 = zeros(length(lati),1) ;new_long1 = zeros(length(long),1) ;for i = 1:length(lati) if new_lati(i) == 0 new_lati(i) = NaN ; end if new_long(i) == 0 new_long(i) = NaN ; end if new_lati1(i) == 0 new_lati1(i) = NaN ; end if new_long1(i) == 0 new_long1(i) = NaN ; end if year(i) > 2008 new_lati(i) = lati(i) ; new_long(i) = long(i) ; end if year(i) > 2013 new_lati1(i) = lati(i) ; new_long1(i) = long(i) ; endendlatlim = [33 39];lonlim = [-102 -94];figureax = usamap(latlim,lonlim) ;set(ax, 'Visible', 'off')states = shaperead('usastatehi',... 'UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);geoshow(ax, states, 'FaceColor', [1.0 0.9 0.7])lat = [states.LabelLat];lon = [states.LabelLon];tf = ingeoquad(lat, lon, latlim, lonlim);hold onh1 = linem(lati, long, 'LineStyle','none', 'LineWidth',2, 'Color','b', ... 'Marker','.', 'MarkerSize',10) ;h2 = linem(new_lati, new_long, 'LineStyle','none', 'LineWidth',2, 'Color','[0.0 0.8 0.3]', ... 'Marker','.', 'MarkerSize',10) ; h3 = linem(new_lati1, new_long1, 'LineStyle','none', 'LineWidth',2, 'Color','r', ... 'Marker','.', 'MarkerSize',10) ;
I have tried using scatterm instead of linem, however didnt know how to keep the corresponding colours.
Any help would be appreciated. Thanks
Gareth
Best Answer