# How to fix x-axis of Dot Plot given .dat file with no x-axis

I am trying to create a dotplot in the same format as the one below

but my .dat file gives me a list of the data with each datapoint contained in a list

When I use the ListPlot[data] function, it gives me an incorrect plot, I am having trouble fixing the x-axis. How do I get it to show each data point one at a time from 0 to 512

• Are you saying that the x-value should be just the index mod 512? Dec 19, 2022 at 20:57
• Yeah, so like the first value would be (1, 0.7159771270002675), second value would be (2,0.3062832599074649) till the final value. I don't know how to get the x-axis to increment by 1 Dec 19, 2022 at 21:02
• ListPlot[testData // Flatten] Dec 19, 2022 at 21:55

Maybe something like this:

testData = Array[{RandomReal[{-1, 1}]} &, 2000];
indexedData = MapIndexed[Join[Mod[#2, 512], #1] &, testData];
ListPlot[indexedData]


Or if you want unique x values up to total number of datapoints:

testData = Array[{RandomReal[{-1, 1}]} &, 512];
indexedData = MapIndexed[Join[#2, #1] &, testData];
ListPlot[indexedData]


You could also just create the list of indices/x-values independently:

testData = Array[{RandomReal[{-1, 1}]} &, 512];
indexedData = Transpose[{Range@Length@testData, Flatten@testData}];
ListPlot[indexedData]

• where do I input the .dat file in this code? I'm very sorry but I don't understand how to get the specific data I need to use into the testData variable. Dec 19, 2022 at 21:09
• I have 512 points of data that I want to plot in order starting from the first piece of data in the file to the last piece of data in the file. All I have is the y-axis value of the data and the x-axis value just needs to be 1 to 512 with 1 being the first data value, 2 being the second data value, 3 being the third data value. and so on. Dec 19, 2022 at 21:11
• I thought you had already executed data = Import[...]. Just substitute data for testData. If that doesn't work, then we'd need to see what the actual result of the Import was, and maybe the actual structure of the .dat file. Dec 19, 2022 at 21:14
• Thank you very much, this worked as intended. Dec 19, 2022 at 21:15