Description
Description of the problem
Under certain cases, the incols (-i) parameter does not work to swap the input columns. From the best that I can tell, the bug happens when there are floats in both columns.
Full code that generated the error
## Test incols (-i) option
# Create some data in a dataframe
data_incols = pd.DataFrame(data={'col1': [-0.5, 0, 0.5], 'col2': [-0.75, 0, 0.75]})
# Write the data to a file
data_incols.to_csv(path_or_buf="data_incols.txt", sep=" ", index=False, header=False)
# Test passing data in a virtual file
fig = pygmt.Figure()
# Plot the dataframe data
fig.plot(data=data_incols, frame=True, region="-1/1/-1/1", projection="X5c", incols="1,0")
fig.savefig("test_i1_virtual.png")
# Test passing data in a file
fig = pygmt.Figure()
# Plot the file data
fig.plot(data="data_incols.txt", frame=True, region="-1/1/-1/1", projection="X5c", incols="1,0")
fig.savefig("test_i1_file.png")
Expected outcome
Two files with the same plot
Actual outcome
Test with virtual file:
Test with ASCII file:
Full error message
No error message
System information
Please paste the output of python -c "import pygmt; pygmt.show_versions()"
:
PyGMT information:
version: v0.4.2.dev4+gebbb0cc0.d20210811
System information:
python: 3.9.6 | packaged by conda-forge | [Clang 11.1.0 ]
executable:anaconda-03/anaconda3/envs/pygmt/bin/python
machine: macOS-11.5-x86_64
Dependency information:
numpy: 1.21.1
pandas: 1.3.1
xarray: 0.19.0
netCDF4: 1.5.7
packaging: 21.0
ghostscript: 9.54.0
gmt: 6.2.0