Scatter plot of 1-D bimodal data from sklearn make_blobs()How to plot 1-d data at given y-value with pylabHow to randomly select an item from a list?How do you read from stdin?Why can't Python parse this JSON data?How to put the legend out of the plotHow to put individual tags for a scatter plotWhy is reading lines from stdin much slower in C++ than Python?Save plot to image file instead of displaying it using Matplotlibmatplotlib scatter plot with different text at each data pointpyplot scatter plot marker sizeHow to make IPython notebook matplotlib plot inline
At what point in European history could a government build a printing press given a basic description?
What is the object moving across the ceiling in this stock footage?
What are the benefits of cryosleep?
How to make a crossed out leftrightarrow?
Four-in-a-line Puzzle
What is the 中 in ダウンロード中?
Does this degree 12 genus 1 curve have only one point over infinitely many finite fields?
Can a wire having 610-670 THz (frequency of blue light) A.C frequency supply, generate blue light?
I think I may have violated academic integrity last year - what should I do?
What do different value notes on the same line mean?
Is floating in space similar to falling under gravity?
Seed ship, unsexed person, cover has golden person attached to ship by umbilical cord
Is CD audio quality good enough for the final delivery of music?
Why is this Simple Puzzle impossible to solve?
Dictionary size reduces upon increasing one element
How do I align equations in three columns, justified right, center and left?
Plot twist where the antagonist wins
Why doesn't the Earth's acceleration towards the Moon accumulate to push the Earth off its orbit?
Is healing by fire possible?
Crossing US border with music files I'm legally allowed to possess
Is there a way to make it so the cursor is included when I prtscr key?
analysis of BJT PNP type - why they can use voltage divider?
How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?
How to capture more stars?
Scatter plot of 1-D bimodal data from sklearn make_blobs()
How to plot 1-d data at given y-value with pylabHow to randomly select an item from a list?How do you read from stdin?Why can't Python parse this JSON data?How to put the legend out of the plotHow to put individual tags for a scatter plotWhy is reading lines from stdin much slower in C++ than Python?Save plot to image file instead of displaying it using Matplotlibmatplotlib scatter plot with different text at each data pointpyplot scatter plot marker sizeHow to make IPython notebook matplotlib plot inline
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
sklearn make_blobs()
function can be used to Generate isotropic Gaussian blobs for clustering.
I am trying to plot the data generated by make_blobs()
function.
import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=1, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
this piece of code gives a normal distribution plot, which makes sense.
blobs, blob_labels = make_blobs(n_samples=1000, n_features=2,
centers=2, random_state=1)
a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)
this piece of code gives a 2-clusters plot, which also makes sense.
I am wondering that is there a way to plot the data generated by make_blobs()
function with params centers=2 n_features=1
.
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
I've tried plt.hist()
, which gives another normal distribution plot.
I have no idea how to use plt.scatter()
with the data.
I cannot image what the plot should look like.
python matplotlib scikit-learn scatter-plot
add a comment |
sklearn make_blobs()
function can be used to Generate isotropic Gaussian blobs for clustering.
I am trying to plot the data generated by make_blobs()
function.
import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=1, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
this piece of code gives a normal distribution plot, which makes sense.
blobs, blob_labels = make_blobs(n_samples=1000, n_features=2,
centers=2, random_state=1)
a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)
this piece of code gives a 2-clusters plot, which also makes sense.
I am wondering that is there a way to plot the data generated by make_blobs()
function with params centers=2 n_features=1
.
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
I've tried plt.hist()
, which gives another normal distribution plot.
I have no idea how to use plt.scatter()
with the data.
I cannot image what the plot should look like.
python matplotlib scikit-learn scatter-plot
add a comment |
sklearn make_blobs()
function can be used to Generate isotropic Gaussian blobs for clustering.
I am trying to plot the data generated by make_blobs()
function.
import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=1, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
this piece of code gives a normal distribution plot, which makes sense.
blobs, blob_labels = make_blobs(n_samples=1000, n_features=2,
centers=2, random_state=1)
a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)
this piece of code gives a 2-clusters plot, which also makes sense.
I am wondering that is there a way to plot the data generated by make_blobs()
function with params centers=2 n_features=1
.
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
I've tried plt.hist()
, which gives another normal distribution plot.
I have no idea how to use plt.scatter()
with the data.
I cannot image what the plot should look like.
python matplotlib scikit-learn scatter-plot
sklearn make_blobs()
function can be used to Generate isotropic Gaussian blobs for clustering.
I am trying to plot the data generated by make_blobs()
function.
import numpy as np
from sklearn.datasets import make_blobs
import matplotlib.pyplot as plt
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=1, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
this piece of code gives a normal distribution plot, which makes sense.
blobs, blob_labels = make_blobs(n_samples=1000, n_features=2,
centers=2, random_state=1)
a = plt.scatter(blobs[:, 0], blobs[:, 1], c=blob_labels)
this piece of code gives a 2-clusters plot, which also makes sense.
I am wondering that is there a way to plot the data generated by make_blobs()
function with params centers=2 n_features=1
.
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
I've tried plt.hist()
, which gives another normal distribution plot.
I have no idea how to use plt.scatter()
with the data.
I cannot image what the plot should look like.
python matplotlib scikit-learn scatter-plot
python matplotlib scikit-learn scatter-plot
edited Mar 25 at 10:52
desertnaut
22k84884
22k84884
asked Mar 24 at 7:10
czlswsczlsws
1677
1677
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Your issue is somewhat unclear.
I've tried
plt.hist()
, which gives another normal distribution plot.
Well, not exactly; it gives a bimodal Gaussian mixture plot:
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
as expected, since now we have centers=2
.
I have no idea how to use
plt.scatter()
with the data.
By definition, a scatter plot needs 2D data; from the docs:
A scatter plot of y vs x with varying marker size and/or color.
while here, due to n_features=1
, we actually have only x and no y.
A 1D "scatter plot" is actually a line, and we can use plot
to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:
val = 0. # this is the value where you want the data to appear on the y-axis.
a = plt.plot(arr, np.zeros_like(arr) + val, 'x')
where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.
Want to use different colors and/or markers for each center?
val = 0. # this is the value where you want the data to appear on the y-axis.
plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
plt.show()
where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000
:
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321496%2fscatter-plot-of-1-d-bimodal-data-from-sklearn-make-blobs%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
Your issue is somewhat unclear.
I've tried
plt.hist()
, which gives another normal distribution plot.
Well, not exactly; it gives a bimodal Gaussian mixture plot:
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
as expected, since now we have centers=2
.
I have no idea how to use
plt.scatter()
with the data.
By definition, a scatter plot needs 2D data; from the docs:
A scatter plot of y vs x with varying marker size and/or color.
while here, due to n_features=1
, we actually have only x and no y.
A 1D "scatter plot" is actually a line, and we can use plot
to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:
val = 0. # this is the value where you want the data to appear on the y-axis.
a = plt.plot(arr, np.zeros_like(arr) + val, 'x')
where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.
Want to use different colors and/or markers for each center?
val = 0. # this is the value where you want the data to appear on the y-axis.
plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
plt.show()
where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000
:
add a comment |
Your issue is somewhat unclear.
I've tried
plt.hist()
, which gives another normal distribution plot.
Well, not exactly; it gives a bimodal Gaussian mixture plot:
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
as expected, since now we have centers=2
.
I have no idea how to use
plt.scatter()
with the data.
By definition, a scatter plot needs 2D data; from the docs:
A scatter plot of y vs x with varying marker size and/or color.
while here, due to n_features=1
, we actually have only x and no y.
A 1D "scatter plot" is actually a line, and we can use plot
to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:
val = 0. # this is the value where you want the data to appear on the y-axis.
a = plt.plot(arr, np.zeros_like(arr) + val, 'x')
where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.
Want to use different colors and/or markers for each center?
val = 0. # this is the value where you want the data to appear on the y-axis.
plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
plt.show()
where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000
:
add a comment |
Your issue is somewhat unclear.
I've tried
plt.hist()
, which gives another normal distribution plot.
Well, not exactly; it gives a bimodal Gaussian mixture plot:
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
as expected, since now we have centers=2
.
I have no idea how to use
plt.scatter()
with the data.
By definition, a scatter plot needs 2D data; from the docs:
A scatter plot of y vs x with varying marker size and/or color.
while here, due to n_features=1
, we actually have only x and no y.
A 1D "scatter plot" is actually a line, and we can use plot
to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:
val = 0. # this is the value where you want the data to appear on the y-axis.
a = plt.plot(arr, np.zeros_like(arr) + val, 'x')
where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.
Want to use different colors and/or markers for each center?
val = 0. # this is the value where you want the data to appear on the y-axis.
plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
plt.show()
where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000
:
Your issue is somewhat unclear.
I've tried
plt.hist()
, which gives another normal distribution plot.
Well, not exactly; it gives a bimodal Gaussian mixture plot:
arr, blob_labels = make_blobs(n_samples=1000, n_features=1,
centers=2, random_state=1)
a = plt.hist(arr, bins=np.arange(int(np.min(arr))-1,int(np.max(arr))+1,0.5), width = 0.3)
as expected, since now we have centers=2
.
I have no idea how to use
plt.scatter()
with the data.
By definition, a scatter plot needs 2D data; from the docs:
A scatter plot of y vs x with varying marker size and/or color.
while here, due to n_features=1
, we actually have only x and no y.
A 1D "scatter plot" is actually a line, and we can use plot
to visualize it, as nicely explained in How to plot 1-d data at given y-value with pylab; in your case:
val = 0. # this is the value where you want the data to appear on the y-axis.
a = plt.plot(arr, np.zeros_like(arr) + val, 'x')
where of course we should keep in mind that the vertical axis is just a convenience for the visualization, and does not say anything for our data which have no y value whatsoever.
Want to use different colors and/or markers for each center?
val = 0. # this is the value where you want the data to appear on the y-axis.
plt.plot(arr[blob_labels==0], np.zeros_like(arr[blob_labels==0]) + val, 'x', color='y')
plt.plot(arr[blob_labels==1], np.zeros_like(arr[blob_labels==1]) + val, '+', color='b')
plt.show()
where for larger samples the situation starts getting somewhat more interesting; notice the overlap for n_samples=10000
:
edited Mar 25 at 4:48
answered Mar 24 at 13:40
desertnautdesertnaut
22k84884
22k84884
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55321496%2fscatter-plot-of-1-d-bimodal-data-from-sklearn-make-blobs%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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