Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rendering arrows using text() instead of polygon() #67

Open
vsimko opened this issue Feb 24, 2017 · 3 comments
Open

Rendering arrows using text() instead of polygon() #67

vsimko opened this issue Feb 24, 2017 · 3 comments

Comments

@vsimko
Copy link
Contributor

vsimko commented Feb 24, 2017

Hi Tarik @tgouhier,

I have a question regarding the arrow() function.
Currently, the function generates a polygon representing the arrow. There are two parameters to control the size of the arrow - width and length.

I think it would be better to print an arrow using the text() function as a character at specified coordinates. This would allow users to use different arrow shapes.

Take a look at my implementation here - arrow2() function:
https://github.com/tgouhier/biwavelet/blob/master/R/phase.plot.R

Notice that my function uses just a single size parameter.

Here are some examples how it might look like when using arrow2 instead of arrow:
image

image

image

image

@vsimko
Copy link
Contributor Author

vsimko commented Mar 1, 2017

I would suggest to:

  • changing arrow.len to arrow.size
  • removing arrow.lwd parameter which can always be computed from arrow.size.
  • keeping arrow.col
  • adding arrow.symbol which would be:
    • "polygon" or NULL or NA for the original polygon-based arrow (default?)
    • single character which would be printed using the text() function

@vsimko
Copy link
Contributor Author

vsimko commented Mar 1, 2017

default could also be a character that we know is safe on all platforms.
I think that intToUtf8(0x279B) ("➛" Drafting Point Rightwards Arrow) might be that character.

@vsimko
Copy link
Contributor Author

vsimko commented Mar 2, 2017

My implementation is half-finished, but I stumbled upon the following problems:

  • testthat-based unit tests don't play well with UTF-8 characters. The following error occurs: conversion failure on '⤑' in 'mbcsToSbcs': dot substituted for <a4>. I would therefore suggest to use character code instead of the character itself, e.g. symbol=0x279b unstead of symbol="➛"

  • When a plot is rendered and later resized, polygon-based arrows keep their shape exactly as rendered while character-based arrows will be automatically resized to keep their aspect-ratio. Both approaches have their advantages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant