geom_dotplot rounding decimal place of dot fill











up vote
0
down vote

favorite












I have created a boxplot of some data using ggplot2 in which I am displaying the data points as dots along the vertical axis of the plot.



bp2 <- ggplot(DBS, aes(DBS_Electrode,Proximal_Lead_Bowing, color=DBS_Electrode)) + 
geom_boxplot() + geom_dotplot(binaxis="y", stackdir="center", fill="white",
dotsize=0.5) + theme_classic()

bp2 + scale_color_manual(values=c("goldenrod3","gray62","dodgerblue1")) +
theme(legend.position = "none") + xlab("") + ylab("Proximal Lead Bowing (mm)")


It appears that my output is rounding the data points to the nearest tenth such that the data points along the axis of each boxplot have several instances in which multiple points are being displayed at the same level along the Y-axis (see plot http://rpubs.com/Gopher16/441664). This is a misrepresentation of the data as there is are no data points that have the exact same measures of proximal lead bowing. (Data was measured to the nearest thousandth). How can I change this output such that all data points are displayed along a vertical axis along each boxplot (i.e. read the data points to the nearest thousandth rather than rounding to the nearest tenth so that no points are displayed at the same level along the Y-axis)?










share|improve this question






















  • could I edit in the image from your RPubs link? That way the image can be seen here and there's no risk of link breakage.
    – Sam Firke
    Nov 21 at 17:48















up vote
0
down vote

favorite












I have created a boxplot of some data using ggplot2 in which I am displaying the data points as dots along the vertical axis of the plot.



bp2 <- ggplot(DBS, aes(DBS_Electrode,Proximal_Lead_Bowing, color=DBS_Electrode)) + 
geom_boxplot() + geom_dotplot(binaxis="y", stackdir="center", fill="white",
dotsize=0.5) + theme_classic()

bp2 + scale_color_manual(values=c("goldenrod3","gray62","dodgerblue1")) +
theme(legend.position = "none") + xlab("") + ylab("Proximal Lead Bowing (mm)")


It appears that my output is rounding the data points to the nearest tenth such that the data points along the axis of each boxplot have several instances in which multiple points are being displayed at the same level along the Y-axis (see plot http://rpubs.com/Gopher16/441664). This is a misrepresentation of the data as there is are no data points that have the exact same measures of proximal lead bowing. (Data was measured to the nearest thousandth). How can I change this output such that all data points are displayed along a vertical axis along each boxplot (i.e. read the data points to the nearest thousandth rather than rounding to the nearest tenth so that no points are displayed at the same level along the Y-axis)?










share|improve this question






















  • could I edit in the image from your RPubs link? That way the image can be seen here and there's no risk of link breakage.
    – Sam Firke
    Nov 21 at 17:48













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have created a boxplot of some data using ggplot2 in which I am displaying the data points as dots along the vertical axis of the plot.



bp2 <- ggplot(DBS, aes(DBS_Electrode,Proximal_Lead_Bowing, color=DBS_Electrode)) + 
geom_boxplot() + geom_dotplot(binaxis="y", stackdir="center", fill="white",
dotsize=0.5) + theme_classic()

bp2 + scale_color_manual(values=c("goldenrod3","gray62","dodgerblue1")) +
theme(legend.position = "none") + xlab("") + ylab("Proximal Lead Bowing (mm)")


It appears that my output is rounding the data points to the nearest tenth such that the data points along the axis of each boxplot have several instances in which multiple points are being displayed at the same level along the Y-axis (see plot http://rpubs.com/Gopher16/441664). This is a misrepresentation of the data as there is are no data points that have the exact same measures of proximal lead bowing. (Data was measured to the nearest thousandth). How can I change this output such that all data points are displayed along a vertical axis along each boxplot (i.e. read the data points to the nearest thousandth rather than rounding to the nearest tenth so that no points are displayed at the same level along the Y-axis)?










share|improve this question













I have created a boxplot of some data using ggplot2 in which I am displaying the data points as dots along the vertical axis of the plot.



bp2 <- ggplot(DBS, aes(DBS_Electrode,Proximal_Lead_Bowing, color=DBS_Electrode)) + 
geom_boxplot() + geom_dotplot(binaxis="y", stackdir="center", fill="white",
dotsize=0.5) + theme_classic()

bp2 + scale_color_manual(values=c("goldenrod3","gray62","dodgerblue1")) +
theme(legend.position = "none") + xlab("") + ylab("Proximal Lead Bowing (mm)")


It appears that my output is rounding the data points to the nearest tenth such that the data points along the axis of each boxplot have several instances in which multiple points are being displayed at the same level along the Y-axis (see plot http://rpubs.com/Gopher16/441664). This is a misrepresentation of the data as there is are no data points that have the exact same measures of proximal lead bowing. (Data was measured to the nearest thousandth). How can I change this output such that all data points are displayed along a vertical axis along each boxplot (i.e. read the data points to the nearest thousandth rather than rounding to the nearest tenth so that no points are displayed at the same level along the Y-axis)?







r ggplot2






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 21 at 17:04









Jake Niederer

12




12












  • could I edit in the image from your RPubs link? That way the image can be seen here and there's no risk of link breakage.
    – Sam Firke
    Nov 21 at 17:48


















  • could I edit in the image from your RPubs link? That way the image can be seen here and there's no risk of link breakage.
    – Sam Firke
    Nov 21 at 17:48
















could I edit in the image from your RPubs link? That way the image can be seen here and there's no risk of link breakage.
– Sam Firke
Nov 21 at 17:48




could I edit in the image from your RPubs link? That way the image can be seen here and there's no risk of link breakage.
– Sam Firke
Nov 21 at 17:48












1 Answer
1






active

oldest

votes

















up vote
0
down vote













First let's make this reproducible, and thus a more useful example for future readers, by using a built-in data set:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_dotplot(binaxis = "y", stackdir = "center", fill = "white", dotsize = 0.5) +
theme_classic()


horizontally adjacent points



This exhibits the behavior you find unwanted: geom_dotplot() bins the points, making multiple points appear horizontally adjacent to each other even though their Sepal.Length values differ.



You could specify binwidth = 0.01 or other small value to geom_dotplot but that's just reducing the problem, and introducing other issues.



You might want geom_jitter instead:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
theme_classic()


jittered points



This preserves the small differences in the unique y-values, which seems to be your chief concern.






share|improve this answer





















  • Thank you for this! This was extremely helpful
    – Jake Niederer
    Nov 21 at 18:08










  • Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
    – Sam Firke
    Nov 21 at 18:23











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%2f53417197%2fgeom-dotplot-rounding-decimal-place-of-dot-fill%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













First let's make this reproducible, and thus a more useful example for future readers, by using a built-in data set:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_dotplot(binaxis = "y", stackdir = "center", fill = "white", dotsize = 0.5) +
theme_classic()


horizontally adjacent points



This exhibits the behavior you find unwanted: geom_dotplot() bins the points, making multiple points appear horizontally adjacent to each other even though their Sepal.Length values differ.



You could specify binwidth = 0.01 or other small value to geom_dotplot but that's just reducing the problem, and introducing other issues.



You might want geom_jitter instead:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
theme_classic()


jittered points



This preserves the small differences in the unique y-values, which seems to be your chief concern.






share|improve this answer





















  • Thank you for this! This was extremely helpful
    – Jake Niederer
    Nov 21 at 18:08










  • Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
    – Sam Firke
    Nov 21 at 18:23















up vote
0
down vote













First let's make this reproducible, and thus a more useful example for future readers, by using a built-in data set:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_dotplot(binaxis = "y", stackdir = "center", fill = "white", dotsize = 0.5) +
theme_classic()


horizontally adjacent points



This exhibits the behavior you find unwanted: geom_dotplot() bins the points, making multiple points appear horizontally adjacent to each other even though their Sepal.Length values differ.



You could specify binwidth = 0.01 or other small value to geom_dotplot but that's just reducing the problem, and introducing other issues.



You might want geom_jitter instead:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
theme_classic()


jittered points



This preserves the small differences in the unique y-values, which seems to be your chief concern.






share|improve this answer





















  • Thank you for this! This was extremely helpful
    – Jake Niederer
    Nov 21 at 18:08










  • Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
    – Sam Firke
    Nov 21 at 18:23













up vote
0
down vote










up vote
0
down vote









First let's make this reproducible, and thus a more useful example for future readers, by using a built-in data set:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_dotplot(binaxis = "y", stackdir = "center", fill = "white", dotsize = 0.5) +
theme_classic()


horizontally adjacent points



This exhibits the behavior you find unwanted: geom_dotplot() bins the points, making multiple points appear horizontally adjacent to each other even though their Sepal.Length values differ.



You could specify binwidth = 0.01 or other small value to geom_dotplot but that's just reducing the problem, and introducing other issues.



You might want geom_jitter instead:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
theme_classic()


jittered points



This preserves the small differences in the unique y-values, which seems to be your chief concern.






share|improve this answer












First let's make this reproducible, and thus a more useful example for future readers, by using a built-in data set:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_dotplot(binaxis = "y", stackdir = "center", fill = "white", dotsize = 0.5) +
theme_classic()


horizontally adjacent points



This exhibits the behavior you find unwanted: geom_dotplot() bins the points, making multiple points appear horizontally adjacent to each other even though their Sepal.Length values differ.



You could specify binwidth = 0.01 or other small value to geom_dotplot but that's just reducing the problem, and introducing other issues.



You might want geom_jitter instead:



ggplot(iris, aes(Species, Sepal.Length)) +
geom_boxplot() +
geom_jitter(width = 0.2) +
theme_classic()


jittered points



This preserves the small differences in the unique y-values, which seems to be your chief concern.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 at 17:42









Sam Firke

9,38325167




9,38325167












  • Thank you for this! This was extremely helpful
    – Jake Niederer
    Nov 21 at 18:08










  • Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
    – Sam Firke
    Nov 21 at 18:23


















  • Thank you for this! This was extremely helpful
    – Jake Niederer
    Nov 21 at 18:08










  • Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
    – Sam Firke
    Nov 21 at 18:23
















Thank you for this! This was extremely helpful
– Jake Niederer
Nov 21 at 18:08




Thank you for this! This was extremely helpful
– Jake Niederer
Nov 21 at 18:08












Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
– Sam Firke
Nov 21 at 18:23




Glad it helped! If you feel the problem is solved, you can mark the answer "accepted" by clicking the check mark.
– Sam Firke
Nov 21 at 18:23


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53417197%2fgeom-dotplot-rounding-decimal-place-of-dot-fill%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

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)