May-26-2021, 05:54 AM
Hi
I am currently facing an problem which might be usual to you as i have just started my party, i thought to take help from Masters.
I am trying to plot a graph for the label which i created
0 100.0
-1 0.0
1 0.0
Since my label has 0 only thats why it is giving 100 viz. correct
when i am executing second part of python:
I am currently facing an problem which might be usual to you as i have just started my party, i thought to take help from Masters.
I am trying to plot a graph for the label which i created
fig, ax = plt.subplots(figsize=(8, 8)) counts = df.label.value_counts(normalize=True) * 100 print(counts)Output is:
Output:0 100.0
Name: label, dtype: float64There supposed to be 0 100.0
-1 0.0
1 0.0
Since my label has 0 only thats why it is giving 100 viz. correct
when i am executing second part of python:
sns.barplot(x=counts.index, y=counts, ax=ax)
ax.set_xticklabels([ 'Neutral', 'Negative','Positive'])
ax.set_ylabel("Percentage")
plt.show()I gives value errorError:--------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-243f41dc9975> in <module>
13
14
---> 15 ax.set_xticklabels([ 'Neutral', 'Negative','Positive'])
16 ax.set_ylabel("Percentage")
17
c:\Bhaskar\ML\env\lib\site-packages\matplotlib\axes\_base.py in wrapper(self, *args, **kwargs)
61
62 def wrapper(self, *args, **kwargs):
---> 63 return get_method(self)(*args, **kwargs)
64
65 wrapper.__module__ = owner.__module__
c:\Bhaskar\ML\env\lib\site-packages\matplotlib\cbook\deprecation.py in wrapper(*args, **kwargs)
449 "parameter will become keyword-only %(removal)s.",
450 name=name, obj_type=f"parameter of {func.__name__}()")
--> 451 return func(*args, **kwargs)
452
453 return wrapper
c:\Bhaskar\ML\env\lib\site-packages\matplotlib\axis.py in _set_ticklabels(self, labels, fontdict, minor, **kwargs)
1794 if fontdict is not None:
1795 kwargs.update(fontdict)
-> 1796 return self.set_ticklabels(labels, minor=minor, **kwargs)
1797
1798 @cbook._make_keyword_only("3.2", "minor")
c:\Bhaskar\ML\env\lib\site-packages\matplotlib\axis.py in set_ticklabels(self, ticklabels, minor, **kwargs)
1715 # remove all tick labels, so only error for > 0 ticklabels
1716 if len(locator.locs) != len(ticklabels) and len(ticklabels) != 0:
-> 1717 raise ValueError(
1718 "The number of FixedLocator locations"
1719 f" ({len(locator.locs)}), usually from a call to"
ValueError: The number of FixedLocator locations (1), usually from a call to set_ticks, does not match the number of ticklabels (3).I want it to display all positive negative and neutral result, but its showing only one graph in display. please help how to achieve this. I dont mind changing whole code.
