dankelley / oce

R package for oceanographic processing
http://dankelley.github.io/oce/
GNU General Public License v3.0
142 stars 42 forks source link

plotSticks() fixes #1271

Closed richardsc closed 6 years ago

richardsc commented 7 years ago

I noticed from issue #1270 that plotSticks() auto labels the x and y axes with range(x) etc. This seems like a bug.

library(oce)
u <- rnorm(100)
v <- rnorm(100)
t <- seq(0, 100, length.out=100)
plotSticks(t, 0, u, v, yscale=5)

image

Also, the y-axis tick labels are confusing, and I think, meaningless. I wonder if there's a better way to scale the arrows so that the y-axis corresponds with the velocity somehow?

dankelley commented 7 years ago

Good catch. I will make it use deparse(substitute(x)) for xlab unless the user gave xlab in the ... argument. That version will get to GH within 1/2 hour.

The scale is a different matter and I don't quite know the best solution. If I were doing it by hand, I'd probably put an isolated arrow in some spot that doesn't have many data, and I'd write something like "1 m/s" beside it. In other words, it would be like a map scale. But where to put it??? Maybe the best solution would be for the doc to have 2 lines that makes a nice label, so with a comment above saying that the user could use similar. Seem OK, @richardsc?

dankelley commented 7 years ago

@richardsc can I ask your opinion?

I can make it label as “x” and “y” if the user doesn’t give labels. But that’s not very R-like. Normally, R would use

xlab=deparse(substitute(x))

etc and so I did that (not pushed to GH) but it’s really ugly for the common case in which the user gives just a single value for y. The label becomes c(0,0,0,0,0) etc, repeated possibly a thousand times, etc, and that seems extreme and a bit nuts. (The same

We have three choices:

  1. “x” and “y” unless xlab and ylab given

  2. no labels unless xlab and ylab given

  3. deparse(substitute(x)) etc unless xlab and ylab given

Of these, the most R like is the third, so I guess that really is my vote.

Q: Your vote?

richardsc commented 7 years ago

Hm. That's an odd side effect, for sure. I think my vote would be the second (or possibly the first). Otherwise every new user who doesn't read the docs is going to get a crazy y label for the 95% use case. I know it's not "R-like", but for that case the R-like solution is terrible-looking.

dankelley commented 7 years ago

I just pushed something that does option 2. I added xlab and ylab as formal arguments, with default values of "", so things will be clear (and R-like) to users.

If this seems ok, please consider closing this, at your leisure.

richardsc commented 7 years ago

Thanks. I think the label fix is good.

I'd like to think a little more about what to do about the scale issue before I close ... the idea of having an "arrow legend" is good, but I wonder if it would be easier to just make the y-axis scale appropriately, to indicate the magnitude of an arrow that is vertically oriented. Does that make sense?

I'll play around a bit when I get a chance.

dankelley commented 7 years ago

Maybe emulate mapScalebar code and UI? This "feels" like a similar task, so it would be good to have a similar UI.

richardsc commented 6 years ago

Yes, gone a bit stale. The reason I guess is that this is for "fixes that we would like" and not "fixes that we imminently need" so it's hard to get motivated to fix things for future uses.

I think it would be nice to have the scale indicated in the plot. That could either by done by having the y-axis labels show the scale (e.g. for a vector that pointed straight "up"), or by adding a horizontal arrow/scale bar that indicates a vector of a certain length. There are some UI/argument decisions to make for such a change ... I wonder if this should maybe wait for a quick f2f discussion?

dankelley commented 6 years ago

Agree on f2f; also, I assigned a low-priority label. (Can you assign labels?) Labels are great because we can make bookmarks for open+high-priority or whatever, for a nice to-do list.

dankelley commented 6 years ago

Possibly of interest -- I was having an email exchange with an undergraduate over the past few days about using stickplots for an upwelling-related task. I basically advised against it. No smoothing -> a total mess where you can't see anything. Enough smoothing to see patterns -> losing the wind events that matter to the process.

I recalled something from a long time ago: when we used pen-on-paper-roll plotters, stickplots were nice. I can recall people laying them out in the hallway and looking at the details. Being able to make a 10-m long roll was a help in that, because you could have a lot of detail without overpainting, because the paper was potentially very long (100m? not sure). Oh, the good old days.

dankelley commented 6 years ago

This issue has been closed, since it seems to have been addressed, and since discussion has stalled. The original reporter should feel free to reopen it, though, or to open new issues that might be related. Thanks.

PS. This is a standardized reply.