Working with Jupyter Lab!
I loaded a simple ASCII file (as I've done 100s of times before...), with three columns and 2000 lines. I did it with
with open(file) as f:
d = f.readlines()
and also with NumPy d = np.loadtxt(file, delimiter=',')
to see if something would change.
All values in the 2nd column (Latitude) are -32. and something and all values in the 3rd column (Longitude) are -52. and something. However, de variation of the data is about the 5th decimal number... (I think this is making things weird!)
When I printed the data on the screen, it seems ok! But when I try to plot them, I got pretty weird stuff... the numbers in the X and Y axis are nonsense, especially the one scaling the x-axis. 1e-5-5.2103e1
I open the data in a spreadsheet (Libre Calc), and there the plot seems alright. Then I save it with another name and tried to load in the Jupyter again and got the same weird result.
I also tried it also using a different computer... same result!
Tried a script using Atom... same result!
Can someone give a clue about what is going on?
The file is shared at:
CodePudding user response:
It looks like your plot is correct, even though the scaling of the axes is quite strange (likely due to the very small range). I plotted the same data using Altair, which was able to handle the axes ranges much better:
import pandas as pd
import altair as alt
with open("lat_long.csv", newline="") as f:
frame = pd.read_csv(f, delimiter=",", header=None, names=["index", "longitude", "latitude"])
alt.Chart(frame).mark_circle(size=10).encode(
alt.X('latitude',
scale=alt.Scale(zero=False)
),
alt.Y('longitude',
scale=alt.Scale(zero=False)
),
).interactive()
The result matches yours, except for the more sensible axes:
My guess is that the pandas plotter is just doing something strange with displaying the axes, but the data is being read in correctly.
CodePudding user response:
This is how matplotlib displays very large and small tick markers. For example, to read the y-axis you take that number at the top and add each tick marker. I'll admit, the number on the x-axis is weird, but you can see a recognizable prefix in there: -5.2103e1. The 1e-5 might just be signifying the decimal place the ticks start at. Looking through the file, the plot makes sense, and the labels do as well.