Dimension change when removing element

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
5
down vote

favorite












I have a list of 3d coordinates.



data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8., 
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]

5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2


The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]] one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot call. Any thought on why this is happening?










share|improve this question





















  • I'm guessing that the array became ragged and not all sublists have the same length any more. E.g., Dimensions[1, 2, 1, 1, 3] === 3. Try Counts[Length /@ LargeArray] and see how many different lengths there are in your array.
    – Sjoerd Smit
    23 hours ago










  • That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
    – Giovanni Baez
    23 hours ago














up vote
5
down vote

favorite












I have a list of 3d coordinates.



data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8., 
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]

5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2


The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]] one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot call. Any thought on why this is happening?










share|improve this question





















  • I'm guessing that the array became ragged and not all sublists have the same length any more. E.g., Dimensions[1, 2, 1, 1, 3] === 3. Try Counts[Length /@ LargeArray] and see how many different lengths there are in your array.
    – Sjoerd Smit
    23 hours ago










  • That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
    – Giovanni Baez
    23 hours ago












up vote
5
down vote

favorite









up vote
5
down vote

favorite











I have a list of 3d coordinates.



data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8., 
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]

5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2


The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]] one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot call. Any thought on why this is happening?










share|improve this question













I have a list of 3d coordinates.



data = 1., 2., 3., 2., 3., 4., 4., 5., 6., 6., 7., 8., 8., 
9., 10.;
Dimensions[data]
data[[All, 2]] = data[[All, 2]]*0;
data
Dimensions[data]
data = DeleteCases[data, 0., 2]
Dimensions[data]

5, 3
1., 0., 3., 2., 0., 4., 4., 0., 6., 6., 0., 8., 8., 0., 10.
5, 3
1., 3., 2., 4., 4., 6., 6., 8., 8., 10.
5, 2


The code abode does as expected it reduces the dimensions from 5,3->5,2
I tried the same code on a larger array, dimensions then go from 11698,3 -> 11698. The elements are still x,z if one calls LargeArray[[1]] one get a list of two elements. However mathematica treats its as on entity. This causes the data to not be interpreted right in a ListPLot call. Any thought on why this is happening?







plotting list-manipulation






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 23 hours ago









Giovanni Baez

424111




424111











  • I'm guessing that the array became ragged and not all sublists have the same length any more. E.g., Dimensions[1, 2, 1, 1, 3] === 3. Try Counts[Length /@ LargeArray] and see how many different lengths there are in your array.
    – Sjoerd Smit
    23 hours ago










  • That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
    – Giovanni Baez
    23 hours ago
















  • I'm guessing that the array became ragged and not all sublists have the same length any more. E.g., Dimensions[1, 2, 1, 1, 3] === 3. Try Counts[Length /@ LargeArray] and see how many different lengths there are in your array.
    – Sjoerd Smit
    23 hours ago










  • That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
    – Giovanni Baez
    23 hours ago















I'm guessing that the array became ragged and not all sublists have the same length any more. E.g., Dimensions[1, 2, 1, 1, 3] === 3. Try Counts[Length /@ LargeArray] and see how many different lengths there are in your array.
– Sjoerd Smit
23 hours ago




I'm guessing that the array became ragged and not all sublists have the same length any more. E.g., Dimensions[1, 2, 1, 1, 3] === 3. Try Counts[Length /@ LargeArray] and see how many different lengths there are in your array.
– Sjoerd Smit
23 hours ago












That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago




That actually might be it, I didnt take into account that if either x or z is 0. it get deleted creating list with just one or zero elements.
– Giovanni Baez
23 hours ago










1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










I take it you are trying to plot the (x,z) coordinates against one another?



It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).



Instead, you could take only the first and last column like:



data[[All, 1, 3]]





share|improve this answer








New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 2




    That was exactly what was happening. Thanks Tyler.
    – Giovanni Baez
    23 hours ago










Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "387"
;
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: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181764%2fdimension-change-when-removing-element%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted










I take it you are trying to plot the (x,z) coordinates against one another?



It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).



Instead, you could take only the first and last column like:



data[[All, 1, 3]]





share|improve this answer








New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 2




    That was exactly what was happening. Thanks Tyler.
    – Giovanni Baez
    23 hours ago














up vote
5
down vote



accepted










I take it you are trying to plot the (x,z) coordinates against one another?



It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).



Instead, you could take only the first and last column like:



data[[All, 1, 3]]





share|improve this answer








New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 2




    That was exactly what was happening. Thanks Tyler.
    – Giovanni Baez
    23 hours ago












up vote
5
down vote



accepted







up vote
5
down vote



accepted






I take it you are trying to plot the (x,z) coordinates against one another?



It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).



Instead, you could take only the first and last column like:



data[[All, 1, 3]]





share|improve this answer








New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









I take it you are trying to plot the (x,z) coordinates against one another?



It is safer to delete the (y) coordinates than replacing them with zeros and deleting zeros. If there are any other zeros in the data you will get undesired results. I suspect this is the case, since your data's new shape is only 116908 (meaning not all entries are the same length).



Instead, you could take only the first and last column like:



data[[All, 1, 3]]






share|improve this answer








New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 23 hours ago









Tyler Chen

1664




1664




New contributor




Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Tyler Chen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 2




    That was exactly what was happening. Thanks Tyler.
    – Giovanni Baez
    23 hours ago












  • 2




    That was exactly what was happening. Thanks Tyler.
    – Giovanni Baez
    23 hours ago







2




2




That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago




That was exactly what was happening. Thanks Tyler.
– Giovanni Baez
23 hours ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f181764%2fdimension-change-when-removing-element%23new-answer', 'question_page');

);

Post as a guest













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

One-line joke