Help! My Shaded Density Plot Isn’t Curving

0
0
Asked By CodeWhiz123 On

Hey everyone! I'm working on a programming assignment for a class, and I'm running into some trouble with my code. The task is to analyze two datasets – one with locations of 10,000 vaccinees and the other with 100 vaccination centers. I need to assign the vaccinees to the centers based on the shortest distance. After running my program on two different computers, I was supposed to compare the execution times and visualize the results with a shaded density plot.

I've run my code 50 times on both computers and collected the execution times, but when I try to generate the shaded density plot, it just shows a vertical line instead of a curve. My professor said it needed to be a curve plot to indicate the distribution difference. Here's the Python code I'm using:

```python
import pandas as pd
import numpy as np
import time
import seaborn as sns
import matplotlib.pyplot as plt
from scipy.stats import ttest_ind

# Load datasets
people_df = pd.read_csv("people.csv")
centre_df = pd.read_csv("centre.csv")
people_coords = people_df[['Lat', 'Lon']].values
centre_coords = centre_df[['Lat', 'Lon']].values

# Haversine formula
# ... (code continues)
```

I'm sure something in my code is causing the plot to not display correctly. Here are the specs for both computers I used:
**Computer 1:** MacBook Pro (2.2 GHz Quad-Core Intel Core i7, 16 GB RAM)
**Computer 2:** MacBook Air (Apple M1, 8 GB RAM)

I've shared some graphs that I generated but I can't quite understand why the shaded density plot isn't working as expected. If anyone can help me identify what's wrong with the code or how to fix my plot, I'd really appreciate it! Thanks!

1 Answer

Answered By DebuggingDynamo On

Another thing to consider is the number of bins you’re using in the histogram. If there are too few bins, it might not show the distribution clearly enough. Try increasing the `bins` parameter in your `histplot()` call. It could also help to increase the range of your execution times if they are too limited. That might make your density plot look more informative!

CodeWhiz123 -

Great suggestion! I'll definitely try adjusting the bins and see how that affects the plot. Appreciate your help!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.