4
votes

I have a 752 data points which i need to plot, I have plotted the data on bar plot using seaborn library in python , but graph i get is very unclear and I am not able to analyze anything through graph , is there any way i can view this graph more clearly and all data points fit with labels seen clearly in python

enter image description here

code written is following

import seaborn as sns
sns.set_style("whitegrid")
ax = sns.barplot(x="Events", y = "Count" , data = Unique_Complaints)
3
what is on your x axis? - Nihal
you should use pandas library - Nihal
I have not tried it, but will replacing the metric y with percentage of the frequency of the event type against the total events rounded to the nearest integer or decimal make the graph more visible? Then the range of values in y will be from 0 to 100 instead from 0 to 70000. This rounding of course will overestimate some of the types with very Low frequency. In that case, I would split the event types into two categories: high frequency and Low frequency in order to get a more clear view. Otherwise, if the visualisation is not optimised, I would suggest the solutions others provided in here. - softdevlife

3 Answers

3
votes

It is always difficult to visualise so many points. Nihal, has rightly pointed that it is best to use Pandas and statistical analysis to extract information from your data. Having said this, IDEs like Spyder and Pycharm and packages like Bokeh allow interactive plots where you can zoom to different parts of the plot. Here is an example with Pycharm:

Code:

    # Import libraries
    import seaborn as sns
    import numpy as np
    import matplotlib.pyplot as plt

    # Exponential decay function
    x = np.arange(1,10, 0.1)
    A = 7000
    y = A*np.exp(-x)

    # Plot the exponential function
    sns.barplot(x = x, y = y)
    plt.show()

Figure without magnification

enter image description here

Magnified figure

enter image description here

1
votes

To see a large amount of data you can use the figure from matplotlib.pyplot like this

from matplotlib.pyplot import figure
figure(num=None, figsize=(20,18), dpi=80, facecolor='w', edgecolor='r')
sns.barplot(x="Events", y = "Count" , data = Unique_Complaints)
plt.show()

I am using this to see a graph with 49 variables and the result is:

My code is

from matplotlib.pyplot import figure
figure(num=None, figsize=(20,18), dpi=256, facecolor='w', edgecolor='r')
plt.title("Missing Value Prercentage")
sns.barplot(miss_val_per, df.columns)
plt.show()

Data I am using is: https://www.kaggle.com/sobhanmoosavi/us-accidents

-1
votes

just swap x and y and try to increase the fig size