Add scale bar for plotting ppp object











up vote
0
down vote

favorite












I would like to add a scale bar to plots of spatstat objects but am not sure how.



Here is a reproducible example:



Plot ppp object called "cells":



data(cells)
plot(cells)


cells



How would I add a scale bar to this plot?










share|improve this question






















  • Please consider upvoting and/or accepting an answer if it solves your problem or explain what is missing.
    – Ege Rubak
    2 days ago















up vote
0
down vote

favorite












I would like to add a scale bar to plots of spatstat objects but am not sure how.



Here is a reproducible example:



Plot ppp object called "cells":



data(cells)
plot(cells)


cells



How would I add a scale bar to this plot?










share|improve this question






















  • Please consider upvoting and/or accepting an answer if it solves your problem or explain what is missing.
    – Ege Rubak
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I would like to add a scale bar to plots of spatstat objects but am not sure how.



Here is a reproducible example:



Plot ppp object called "cells":



data(cells)
plot(cells)


cells



How would I add a scale bar to this plot?










share|improve this question













I would like to add a scale bar to plots of spatstat objects but am not sure how.



Here is a reproducible example:



Plot ppp object called "cells":



data(cells)
plot(cells)


cells



How would I add a scale bar to this plot?







sp spatstat






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 10 at 16:38









Carrie Perkins

263




263












  • Please consider upvoting and/or accepting an answer if it solves your problem or explain what is missing.
    – Ege Rubak
    2 days ago


















  • Please consider upvoting and/or accepting an answer if it solves your problem or explain what is missing.
    – Ege Rubak
    2 days ago
















Please consider upvoting and/or accepting an answer if it solves your problem or explain what is missing.
– Ege Rubak
2 days ago




Please consider upvoting and/or accepting an answer if it solves your problem or explain what is missing.
– Ege Rubak
2 days ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote















I just Googled 'spatstat scale bar' and the second hit was the help file for yardstick() while the top hit concerned the plot method for the yard stick. The title of the help file is "yardstick: Text, Arrow or Scale Bar in a Diagram". Maybe that is what you are looking for.



E.g:



library(spatstat)
W <- union.owin(owin(c(0,1),c(0,5)), owin(c(0,5),c(4,5)))
X <- runifpoint(100, win = W)
plot(X, main = "")
y <- yardstick(3,1,4,1, txt = "1 unit")
plot(y, add = TRUE)




Created on 2018-11-11 by the reprex package (v0.2.1)






share|improve this answer























  • Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
    – Carrie Perkins
    Nov 11 at 2:45










  • The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
    – Ege Rubak
    Nov 11 at 21:51











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241073%2fadd-scale-bar-for-plotting-ppp-object%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote















I just Googled 'spatstat scale bar' and the second hit was the help file for yardstick() while the top hit concerned the plot method for the yard stick. The title of the help file is "yardstick: Text, Arrow or Scale Bar in a Diagram". Maybe that is what you are looking for.



E.g:



library(spatstat)
W <- union.owin(owin(c(0,1),c(0,5)), owin(c(0,5),c(4,5)))
X <- runifpoint(100, win = W)
plot(X, main = "")
y <- yardstick(3,1,4,1, txt = "1 unit")
plot(y, add = TRUE)




Created on 2018-11-11 by the reprex package (v0.2.1)






share|improve this answer























  • Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
    – Carrie Perkins
    Nov 11 at 2:45










  • The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
    – Ege Rubak
    Nov 11 at 21:51















up vote
0
down vote















I just Googled 'spatstat scale bar' and the second hit was the help file for yardstick() while the top hit concerned the plot method for the yard stick. The title of the help file is "yardstick: Text, Arrow or Scale Bar in a Diagram". Maybe that is what you are looking for.



E.g:



library(spatstat)
W <- union.owin(owin(c(0,1),c(0,5)), owin(c(0,5),c(4,5)))
X <- runifpoint(100, win = W)
plot(X, main = "")
y <- yardstick(3,1,4,1, txt = "1 unit")
plot(y, add = TRUE)




Created on 2018-11-11 by the reprex package (v0.2.1)






share|improve this answer























  • Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
    – Carrie Perkins
    Nov 11 at 2:45










  • The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
    – Ege Rubak
    Nov 11 at 21:51













up vote
0
down vote










up vote
0
down vote











I just Googled 'spatstat scale bar' and the second hit was the help file for yardstick() while the top hit concerned the plot method for the yard stick. The title of the help file is "yardstick: Text, Arrow or Scale Bar in a Diagram". Maybe that is what you are looking for.



E.g:



library(spatstat)
W <- union.owin(owin(c(0,1),c(0,5)), owin(c(0,5),c(4,5)))
X <- runifpoint(100, win = W)
plot(X, main = "")
y <- yardstick(3,1,4,1, txt = "1 unit")
plot(y, add = TRUE)




Created on 2018-11-11 by the reprex package (v0.2.1)






share|improve this answer
















I just Googled 'spatstat scale bar' and the second hit was the help file for yardstick() while the top hit concerned the plot method for the yard stick. The title of the help file is "yardstick: Text, Arrow or Scale Bar in a Diagram". Maybe that is what you are looking for.



E.g:



library(spatstat)
W <- union.owin(owin(c(0,1),c(0,5)), owin(c(0,5),c(4,5)))
X <- runifpoint(100, win = W)
plot(X, main = "")
y <- yardstick(3,1,4,1, txt = "1 unit")
plot(y, add = TRUE)




Created on 2018-11-11 by the reprex package (v0.2.1)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 11 at 21:49

























answered Nov 11 at 1:14









Ege Rubak

1,7791511




1,7791511












  • Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
    – Carrie Perkins
    Nov 11 at 2:45










  • The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
    – Ege Rubak
    Nov 11 at 21:51


















  • Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
    – Carrie Perkins
    Nov 11 at 2:45










  • The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
    – Ege Rubak
    Nov 11 at 21:51
















Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
– Carrie Perkins
Nov 11 at 2:45




Thank you very much for your suggestion. Yes, i did look into yardstick, but am not sure how to use it for my real data. The window in my real data is very narrow and as far as I understand, it seems that the yardstick will have to be placed at coordinates within the window itself, where there isn't really any free space. I am looking for a way to put a scale bar outside of the window.
– Carrie Perkins
Nov 11 at 2:45












The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
– Ege Rubak
Nov 11 at 21:51




The coordinates of the observation window follow the bounding box of the rectangle. See my update for an example where a stick is plotted outside the window, but inside the bounding box (frame).
– Ege Rubak
Nov 11 at 21:51


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241073%2fadd-scale-bar-for-plotting-ppp-object%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

さくらももこ

13 indicted, 8 arrested in Calif. drug cartel investigation