0

I am trying to make a column graph where the y-axis is the mean grain size, the x-axis is the distance along the transect, and each series is a date and/or number value (it doesn't really matter).

I have been trying a few different methods in Excel 2010 but I cannot figure it out. My hope is that, lets say at the first location, 9, there will be three columns and then at 12 there will be two columns. If it matter at all, lets say the total distance is 50. The result of this data should have 7 sets of columns along the transect/x-axis.

I have tried to do this using python but my coding knowledge is close to nil. Here is my code so far:

import numpy as np    
import matplotlib.pyplot as plt

grainsize = [0.7912, 0.513, 0.4644, 1.0852, 1.8515, 1.812, 6.371, 1.602, 1.0251, 5.6884, 0.4166, 24.8669, 0.5223, 37.387, 0.5159, 0.6727]    
series = [2, 3, 4, 1, 4, 2, 3, 4, 1, 4, 1, 4, 1, 4, 1, 4]    
distance = [9, 9, 9, 12, 12, 15, 15, 15, 17, 17, 25, 25, 32.5, 32.5, 39.5, 39.5]

If someone happen to know of a code to use, it would be very helpful. A recommendation for how to do this in Excel would be awesome too.

nicoguaro
  • 3,629
  • 1
  • 32
  • 57
  • 1
    Can you present what you've tried in Python at least? This site is meant for programming issues, not for excel support. If you wish to know how this is done in excel, I recommend you to post the question on [Super User](http://superuser.com/) instead. – Demitrian Jan 20 '16 at 21:14
  • Sorry I am new to on this website. I edited my question – user5818107 Jan 20 '16 at 21:18
  • No problem. Have you tried parsing the data as well? It is difficult to assist you if we've only got your dataset to go by. – Demitrian Jan 20 '16 at 21:22
  • Thank you for the edit. I am still trying to understand stackoverflow. – user5818107 Jan 20 '16 at 21:27
  • That's OK. Have you got some code to add where you parse the data? If you've only got the input, it'll be difficult to help you. – Demitrian Jan 20 '16 at 21:28
  • I posted this in super user like you suggested. I only have that input since I don't know where to go next. I wish I was better at this. Sorry. – user5818107 Jan 20 '16 at 21:39
  • Do you have an example of what you want? I don't really understand it. – nicoguaro Jan 20 '16 at 21:39
  • I hope the users on Super User can help you. If you find that you are in need of programming aid once you've obtained more information, @user5818107, then you can return and either update your question or make a new one. – Demitrian Jan 20 '16 at 21:43
  • The second graph in this question. But x-axis is distance, y-axis is grain size. http://stackoverflow.com/questions/14270391/python-matplotlib-multiple-bars – user5818107 Jan 20 '16 at 21:45
  • Have you tried putting your data into the example you cite? Just matching up x and distance, etc., should get you a long way. – cphlewis Jan 21 '16 at 03:01

1 Answers1

0

There's a plotting library called seaborn, built on top of matplotlib, that does this in one line. Your example:

enter image description here

import numpy as np     
import seaborn as sns 
from matplotlib.pyplot import show

grainsize = [0.7912, 0.513, 0.4644, 1.0852, 1.8515, 1.812, 6.371,
             1.602, 1.0251, 5.6884, 0.4166, 24.8669, 0.5223, 37.387, 0.5159, 0.6727]     
series = [2, 3, 4, 1, 4, 2, 3, 4, 1, 4, 1, 4, 1, 4, 1, 4]
distance = [9, 9, 9, 12, 12, 15, 15, 15, 17, 17, 25, 25, 32.5, 32.5, 39.5, 39.5]

ax = sns.barplot(x=distance, y=grainsize, hue=series, palette='muted')

ax.set_xlabel('distance') 
ax.set_ylabel('grainsize') 
show()

You will be able to do a lot even as a total newbie by editing the many examples in the seaborn gallery. Use them as training wheels: edit only one thing at a time and think about what changes.

cphlewis
  • 15,759
  • 4
  • 46
  • 55