In response to the question posted here, Farid Cher provided a slick modification to choro.legend that enabled R users to control the amount of space inserted between legend colors and their description. I am trying to use Farid's modification to choro.legend, but regardless of the value I set for the space_reduction attribute, I get the following error message:

Error in legend(x = px, y = py, legend = rep(" ", length(res)), fill = sh$cols, : 'text.width' must be numeric, >= 0       

My function call looks like:

choro.legend(-85.80, 45.3, tneffort.shades, title='Trapnet lifts per year',  cex=0.6, bty="n", fmt = "%0.0f", space_reduction=4000)

Can anyone identify the source of the problem? Apologies to the community for initially posting this question as a comment to the original post.

1 Answer 1


I tried and got "unused argument (space_reduction = 4000). Try without this argument, removing it returned results for me.

well.. I used this choro.legend(514000, 175000,shade,title='My Legend',cex=.8, bty = "n", fmt = "%0.0f") which is a different coord system than your example. Maybe your "-85.80" has something to do with it.

  • I also was wondering if the coordinate system was the issue, but still am not sure what the fix would be...
    – Darryl H
    Sep 21, 2017 at 15:33
  • I tried the negative value and it doesn't return any errors but still grumbled about the space_reduction. Have you tried removing space_reduction?
    – user92055
    Sep 21, 2017 at 19:03
  • After that the next thing I would try is another coordinate system. UTM is a good start.
    – user92055
    Sep 21, 2017 at 19:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.