Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need Python 3 help. I'm trying to display this data as a table using matplotlib but I'm having trouble. Can anyone assist? So we

I need Python 3 help.

I'm trying to display this data as a table using matplotlib but I'm having trouble. Can anyone assist?

So we have 18 rows and 22 columns, not including the index 'Lab_Test_Info'.

image text in transcribed

Code so far..

import matplotlib.pyplot as plt; import pandas as pd; import numpy as np; # %matplotlib inline

# data to the chart df = pd.read_csv('C:/users/cchar/bamberger_soil_results.csv', index_col=0) data = df.values column_labels = df.columns.tolist() index_labels = df.index.tolist()

# settings bar_width = 0.5 index_position = np.arange(len(column_labels)) + 0.2 colors = plt.cm.BuPu(np.linspace(0, 0.5, len(index_labels)))

# creating matplotlib graph plt.figure(figsize=(10, 9))

# return four zeros y_offset = np.zeros(len(column_labels))

# to store text to later insert table cell_text = []

# creating the graph for row_index in range(len(index_labels)): plt.bar( column_labels, data[row_index], bar_width, bottom=y_offset, color=colors[row_index] ) y_offset += data[row_index] cell_text.append(['{:1.1f}'.format for y_value in y_offset]) data.table = plt.table( cellText = cell_text, rawLabels = index_labels, colLabels = column_labels, rowColours=colors, colWidths=[0.25, 0.25, 0.25, 0.25], loc='bottom' )

data_table.scale(1, 2) data_table.set_fontsize(12) plt.xticks(()) plt.subplots_adjust(left=0.01, bottom=0.25) plt.title('Soil Test Results')

Lab_Test_Info SoilpHlRatic OrganicMatt SoilRespir H2OTotal H20OrgNH20OrgCF H20OrgNI OrganicNF OrganicNFH3AOrgan Organic PR Organic PR SoilHealth Tot_Liv_M Functiona FungiRatic Protozoa B_glucosic Permanga WHC_inch Macroaggi Microaggre WARD Multiple_PLFA_(BALSER)_Nov_2017 - Wildlife Compo 2000.01 1.404 0.1511 10 WARD Multiple_PLFA_(BALSER)_Nov_2017 - Closest-In Campo 2118.74 1.428 0.1661 10 WARD Multiple_Soil3_Nov_2017 - Wildlife Compo 7.9 4.3 WARD Multiple_Soil3_Nov_2017 - Closest-In Campo 7.9 4 WARD_Multiple_Soil3_Nov_2017 - Wildlife Campo 7.9 4.3 WARD_Multiple_Soil3_Nov_2017 - Closest-In Campo 7.9 4 WARD_Multiple_PLFA_(BALSER)_Nov_2017 - Wildlife Campo 2000.01 1.404 0.1511 10 WARD_Multiple_PLFA_(BALSER)_Nov_2017 - Closest In-Campo 2118.74 1.428 0.1661 10 WARD Multiple_HANEY_+_PLFA_+_WHC_May_2019 - Wildlife P 8.2 4.1 26 16.7 18.7 1.2 5.6 11.2 1.7 0.4 1.2 10.54 3319.47 1.51 0.418 10 0.21 WARD Multiple_HANEY_+_PLFA_+_WHC_May_2019 - Turkey Ho 8.3 3.4 49.6 16.5 23.8 1.2 8.3 8.2 2.2 0.8 1.3 14.46 3880.34 1.584 0.523 0.0038 0.29 WARD_Multiple_HANEY_+_PLFA_+_WHC_May_2019 - Wildlife 8.2 4.1 26 16.7 18.7 1.2 5.6 11.2 1.7 0.4 10.54 3319.47 1.51 0.418 10 0.21 WARD_Multiple_HANEY_+_PLFA_+_WHC_May_2019 - Turkey Ho 8.3 3.4 49.6 16.5 23.8 1.2 8.3 8.2 2.2 0.8 14.46 3880.34 1.584 0.523 0.0038 0.29 Kroeger_Bamberger_Misc_10-27-2021 - Wildlife Preserve 36.4 0.19 31.6 16.7! Kroeger_Bamberger_Misc_10-27-2021 - Turkey Hollow 81.6 0.22 39.3 17.71 Kroeger_Bamberger_Haney_10-27-21 - Wildlife Presevere 8.3 3.1 6.39 14 1.81 5.54 0.9 0.5 0.4 0.2 4.4 Kroeger_Bamberger_Haney_10-27-21 - Turkey Fallow 8.2 5.8 5.31 14.8 1.88 5.31 0 0.5 0.5 0 7 Kroeger_Bamberger_PLFA_10-29-2021 - Wildlife Preserve 2126.31 1.466 0.2151 11 Kroeger Bamberger PLFA 10-29-2021 - Turkey Follow 4024.43 1.553 0.3294 0.0079 + 1 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

Project management skills and/or experience desirable

Answered: 1 week ago