Home>

I want to enlarge the plot of data in Python so that the points are not crushed.

I have a function to plot csv data, but I can't see the whole picture of the data.

Corresponding source code
plt.scatter (df_cloud006 ['longitude'], df_cloud006 ['latitude'], s = 0.3)
plt.ylabel ('latitude')
plt.xlabel ('longitude')
plt.xlim (139.2626,139.2630) # I don't know this value
plt.ylim (36.10295,36.11028) # I don't know this value
plt.show ()
36.10828456833334 139.26255583
36.10829499666667 139.26265564666667
36.108304643333334 139.26262115833333
36.108300045 139.26263219833334
36.108305103333336 139.26262844
36.108311335 139.26261488833333
36.108304608333334 139.26261360166666
36.108287585 139.26261429833332
36.10831044166666 139.26258242666665
36.10830223333333 139.26256272833334
36.10830603 139.26254516166668
36.108302216666665 139.26254491
36.10830335833334 139.26254555166668
36.1083042 139.262544815
・
・
・
・
  • Answer # 1

    How about something like this?

    import pandas as pd
    import matplotlib.pyplot as plt
    import io
    import japanize_matplotlib
    test_csv ='''
    longitude latitude
    36.10828456833334 139.26255583
    36.10829499666667 139.26265564666667
    36.108304643333334 139.26262115833333
    36.108300045 139.26263219833334
    36.108305103333336 139.26262844
    36.108311335 139.26261488833333
    36.108304608333334 139.26261360166666
    36.108287585 139.26261429833332
    36.10831044166666 139.26258242666665
    36.10830223333333 139.26256272833334
    36.10830603 139.26254516166668
    36.108302216666665 139.26254491
    36.10830335833334 139.26254555166668
    36.1083042 139.262544815
    '''
    df_test_csv = pd.read_csv (io.StringIO (test_csv), delim_whitespace = True)
    plt.scatter (df_test_csv ['longitude'], df_test_csv ['latitude'])
    plt.axis ([df_test_csv ['longitude']. min (), df_test_csv ['longitude'] .max (),
              df_test_csv ['latitude'] .min (), df_test_csv ['latitude'] .max ()])
    plt.ylabel ('latitude')
    plt.xlabel ('longitude')
    plt.show ()