geom_dotplot rounding decimal place of dot fill












0















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 '18 at 17:48
















0















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 '18 at 17:48














0












0








0








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 '18 at 17:04









Jake NiedererJake Niederer

74




74













  • 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 '18 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 '18 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 '18 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 '18 at 17:48












1 Answer
1






active

oldest

votes


















0














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 '18 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 '18 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',
autoActivateHeartbeat: false,
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









0














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 '18 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 '18 at 18:23
















0














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 '18 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 '18 at 18:23














0












0








0







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 '18 at 17:42









Sam FirkeSam Firke

10.4k35469




10.4k35469













  • Thank you for this! This was extremely helpful

    – Jake Niederer
    Nov 21 '18 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 '18 at 18:23



















  • Thank you for this! This was extremely helpful

    – Jake Niederer
    Nov 21 '18 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 '18 at 18:23

















Thank you for this! This was extremely helpful

– Jake Niederer
Nov 21 '18 at 18:08





Thank you for this! This was extremely helpful

– Jake Niederer
Nov 21 '18 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 '18 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 '18 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.




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

Guess what letter conforming each word

Port of Spain

Run scheduled task as local user group (not BUILTIN)