1

I'm trying to plot in a single image, multiple columns of a table.

The idea is to optimize the process with a loop.

It is important to note that all the columns share the same y-axis, and that the x scale varies for each column.

The Final result should look something like this:

enter image description here

I've already tried some things, but with no success, in my code I'm creating several figures, only plotting in the first graph:

def facies_plot_all(logs):
    logs = sort_values(by='y')
    ztop=logs.Y.min(); zbot=logs.Y.max()
    
    for col in logs.columns:
        numcol = (logs.shape[1])
        f, ax = plt.subplots (nrows=1, ncols=numcol, figsize (20,25))
        ax[x+1].plot(logs[col],logs.Y,'-')

I'm relatively new to programming and still searching for a way to solve this issue. Any help will be welcome!

1 Answer 1

1

Put subplots outside of for loop:

logs = sort_values(by='y')
ztop=logs.Y.min(); zbot=logs.Y.max()

numcol = (logs.shape[1])
f, axes es= plt.subplots (nrows=1, ncols=numcol, 
                        sharey=True,
                        figsize=(20,25))

for (ax, col) in zip(axes,logs.columns):
    ax.plot(logs[col],logs.Y,'-')
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.