0
$\begingroup$

In trying to recreate results from another question I had asked (here)

Code is:

dataHist7 = {{16.5, 77.8}, {34.5, 63.5}, {54.5, 63.8}, {106.5, 42.4}, {124.5, 41.7}, {142.5, 14.6}, {160.5, 33.9}, {178.5, 29.4}, {196.5, 33.5}, {214.5, 30.9}, {232.5, 31.1}, {250.5, 21.5}, {268.5, 4.3}, {286.5, 6.4}, {322.5, 7.5}, {340.5, 4.5}, {358.5 , 11.0}, {376.5, 14.0}, {394.5, 14.0}, {466.5, 0.6}, {484.5, 2.2}, {520.5, 9.4}, {538.5, 4.1}, {646.5, 2.2}, {682.5, 0.6}}

data = Transpose[{dataHist7[[All, 1, 1]], dataHist7[[All, 2, 1]]}];
ListLogPlot[data]

Which returns the errors:

Part::partd: Part specification {{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}[[All,1,1]] is longer than depth of object.
Part::partd: Part specification {{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}[[All,2,1]] is longer than depth of object.

Transpose::nmtx: The first two levels of {{{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}[[All,1,1]],{{16.5,77.8},{34.5,63.5},<<21>>,{646.5,2.2},{682.5,0.6}}[[All,2,1]]} cannot be transposed.

ListLogPlot::lpn: Transpose[{{{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}[[All,1,1]],<<1>>}] is not a list of numbers or pairs of numbers.

ListLogPlot::lpn: Transpose[{{{16.5,77.8},{34.5,63.5},{54.5,63.8},{106.5,42.4},{124.5,41.7},{142.5,14.6},{160.5,33.9},{178.5,29.4},{196.5,33.5},{214.5,30.9},{232.5,31.1},{250.5,21.5},{268.5,4.3},{286.5,6.4},{322.5,7.5},{340.5,4.5},{358.5,11.},{376.5,14.},{394.5,14.},{466.5,0.6},{484.5,2.2},{520.5,9.4},{538.5,4.1},{646.5,2.2},{682.5,0.6}}[[All,1,1]],<<1>>}] is not a list of numbers or pairs of numbers.

I assume the later errors are caused by the partd error. The error sheet suggests that there's too few indices available for the transpose, but I don't really understand how as it's just a list of pairs? I'd like to know why this happens and how to remedy it? Thanks

$\endgroup$
4
  • $\begingroup$ What is dataHist7[[All, 1, 1]] supposed to do? You're using 3 indices to index an array of depth 2. Surely it should be dataHist7[[All, 1]] and dataHist7[[All, 2]]? And why not just ListLogPlot[dataHist7]? $\endgroup$ Mar 2 at 12:07
  • $\begingroup$ This was one part of the answer I was trying to follow I didn't understand well - in fact part of the recreation purpose of recreating it was to understand it. The link is in the question if that is of any help, but truthfully, I'm not totally sure. Would still be good to understand the error either way $\endgroup$
    – Epideme
    Mar 2 at 12:15
  • $\begingroup$ In that question, the array uses Around objects, which adds one extra layer of depth to the array. $\endgroup$ Mar 2 at 12:18
  • $\begingroup$ Would that not return 1 layer too few on the depth instead of 1 layer too many? Okay, so it's down to me have reused the same data pool but with just single figures? $\endgroup$
    – Epideme
    Mar 2 at 12:20
3
$\begingroup$

Let us see what are you doing. This:

dataHist7[[All, 1]]

yields the list of the first elements of your pairs:

{16.5, 34.5, 54.5, 106.5, 124.5, 142.5, 160.5, 178.5, 196.5, 214.5, 
232.5, 250.5, 268.5, 286.5, 322.5, 340.5, 358.5, 376.5, 394.5, 466.5, 
484.5, 520.5, 538.5, 646.5, 682.5}

If you write dataHist7[[All, 1, 1]] you get the error message: "Part::partd: Part specification <<1>> is longer than depth of object." It indicates that the element with the tree coordinates All, 1, 1 does not exist and, therefore, the evaluation of dataHist7[[All, 1, 1]] is not possible. Mma then returns the original list, as it does in the cases when the calculation is impossible.

If instead, you put data = Transpose[{dataHist7[[All, 1]], dataHist7[[All, 2]]}] Mma will evaluate it without the error message. However, in this case, data will be identical to the original list dataHist7. In that case, you can simply plot this:

ListLogPlot[dataHist7]

yielding the following:

enter image description here

Have fun!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.