Python Forum
Likert survey data plot error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Likert survey data plot error
#1
Hi,
I just have read and checked that idea here:
https://stackoverflow.com/questions/7097...ale-python

then copying/pasting first example:
import plot_likert
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

rng = np.random.default_rng(seed=42)
data = pd.DataFrame(rng.choice(plot_likert.scales.agree, (200, 2)), columns=['Q1', 'Q2'])

ax = plot_likert.plot_likert(data, plot_likert.scales.agree, plot_percentage=True, figsize=(14, 4))
for bars, color in zip(ax.containers[1:], ['white'] + ['black'] * 2 + ['white'] * 2):
    ax.bar_label(bars, label_type='center', fmt='%.1f %%', color=color, fontsize=15)

plt.tight_layout()
plt.show()
and get this:
Error:
TypeError: DataFrame.set_axis() got an unexpected keyword argument 'inplace'
So went to the second example from this link, adapting a bit a data:
import plot_likert
import pandas as pd

rng = np.random.default_rng(seed=42)
data = pd.DataFrame(rng.choice(plot_likert.scales.agree, (200, 2)), columns=['Q1', 'Q2'])

# define my selections
myscale1 = \
        ['Strongly disagree',
     'Disagree',
     'Neither agree nor disagree',
     'Agree',
     'Strongly agree']
# create a likert plot
ax1  = plot_likert.plot_likert(data, myscale1, plot_percentage=True, figsize=(20,20), colors=plot_likert.colors.likert5)
ax1.set_title(('Casually watch big matches (21-34 year old)'), fontsize=30)
ax1.set_ylabel('Football/Soccer Moments',fontdict={'fontsize':28})
ax1.set_xlabel('% Breakdown',fontdict={'fontsize':28})
ax1.tick_params(axis='y', labelsize= 15)
ax1.tick_params(axis='x', labelsize= 10)

for bars, color in zip(ax1.containers[1:], ['white'] + ['black'] * 2 + ['white'] * 2):
    ax1.bar_label(bars, label_type='center', fmt='%.1f %%', color=color, fontsize=15)
and received yet still the same error:
Error:
TypeError: DataFrame.set_axis() got an unexpected keyword argument 'inplace'
How to rectify this, please ?
Reply


Messages In This Thread
Likert survey data plot error - by Andrzej_Andrzej - Jul-15-2023, 08:45 PM
RE: Likert survey data plot error - by snippsat - Jul-16-2023, 07:53 AM
RE: Likert survey data plot error - by snippsat - Jul-16-2023, 11:23 AM
RE: Likert survey data plot error - by snippsat - Jul-16-2023, 11:42 AM
RE: Likert survey data plot error - by deanhystad - Jul-16-2023, 10:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Value Error when Trying to Plot Filtered Waveforms mkohler 1 1,327 May-09-2024, 05:33 PM
Last Post: deanhystad
  Error when animating 3D plot Tee 4 2,223 Jul-03-2023, 08:49 PM
Last Post: Tee
  Plot a pandas data fram via pyqtgraph with an modul import and qt designer widget Nietzsche 0 1,500 May-29-2023, 02:42 PM
Last Post: Nietzsche
  Create simple live plot of stock data dram 2 3,821 Jan-27-2023, 04:34 AM
Last Post: CucumberNox
Thumbs Up Python 3 Jupyter notebook ternary plot data nicholas 0 1,819 Jan-21-2023, 05:01 PM
Last Post: nicholas
  pandas.errors.ParserError: Error tokenizing data. C error: Expected 9 fields in line Anldra12 9 21,762 Jun-15-2021, 08:16 AM
Last Post: Anldra12
  Plot data from CSV allen04 2 3,102 Jan-03-2021, 10:30 AM
Last Post: Axel_Erfurt
  How to plot intraday data of several days in one plot mistermister 3 3,949 Dec-15-2020, 07:43 PM
Last Post: deanhystad
  Creating Complex Color Spectrum Plot From Data JoeDainton123 2 2,818 Sep-15-2020, 08:09 AM
Last Post: DPaul
  How to plot data from live datasource? Makada 14 7,761 Sep-06-2020, 07:13 PM
Last Post: Makada

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020