Minimal-code to get axes limits of log-log plots, but using gscatter
6 views (last 30 days)
I used to specify scatter plots using loglog(X,Y,'o') to plot little circles at the data points. Now, gscatter(X,Y,GroupVector,'br','o') allows me to designate different colours for different data points. In my case, I only had two groups, and with logical GroupVector above designating which points belongs to which group. The 'br' says to use blue and red for the two groups.
Unfortunately, gscatter doesn't have a log scale option. I can set(gca,'xscale','log','yscale','log'), but I get complaints that negative axis limits are ignored. Sure enough, that is because the axis limits do include negative numbers, even if the data does not. As a result of this, the log scale scatter plot does not *automatically* have the nice axis limits that loglog(X,Y,'o') has.
My nonideal solution has been to create both plots, then copy the axes limits from the loglog plot to the gscatter plot. It seems heavily redundant. It sure would be nice to have a log scale option for gscatter. In the meantime, what is the most minimal code alternative of replicating loglog axes limits for gscatter? My method *might* be "minimal code", but I mean without duplicating plots.