Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

The goal of the code is to create a scatter plot that maps California cities based on their longitude and latitude coordinates, while also visually representing their population and area. The population is reflected by the color of the points, and the area is reflected by the size of the points on the plot. This visualization helps in understanding the geographic distribution of cities in California and comparing their sizes and populations.

Functionality: Data Loading and Extraction:

The code starts by loading a CSV file named "california_cities.csv" into a Pandas DataFrame. It extracts relevant columns: latd (latitude), longd (longitude), population_total, and area_total_km2. These columns represent the latitude, longitude, total population, and total area (in square kilometers) of California cities, respectively. Plot Configuration:

The code sets up the plot style using Seaborn for improved aesthetics. It then creates a scatter plot where: X-axis (longitude): Represents the longitude of each city. Y-axis (latitude): Represents the latitude of each city. Color (c): The color of each point represents the population size, scaled logarithmically using np.log10(population) and colored using the viridis colormap. Size (s): The size of each point represents the area of the city. Plot Adjustments:

The axis is set to equal aspect ratio (plt.axis('equal')) to ensure that distances on the x and y axes are proportional. Labels are added to the x and y axes (Longitude and Latitude). A color bar is added to the right side of the plot, indicating the scale of the logarithm of the population. The color scale is limited to a range between 3 and 7 on the log scale (plt.clim(3, 7)). Legend Creation:

A legend is created to indicate the meaning of the point sizes. Since scatter plots don't automatically generate legends based on size, empty scatter plots are drawn with varying sizes to represent areas of 100, 300, and 500 km². Plot Title and Display:

The plot is titled "Area and Population of California Cities". Finally, plt.show() is called to display the plot.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages