Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1082407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:17:33+00:00 2026-05-16T22:17:33+00:00

If I wanted to make a combined image like the one shown below (

  • 0

If I wanted to make a combined image like the one shown below (original source here),
could you point me to the matplotlib objects do I need to assemble? I’ve been trying to work with AxesImage objects and I’ve also downloaded SciKits Timeseries – but do I need this, or can is it as easy to use strptime, mktime, and strftime from the time module and roll my own custom axes? Thanks ~

alt text

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:17:33+00:00Added an answer on May 16, 2026 at 10:17 pm

    You shouldn’t need any custom axes. The Timeseries Scikit is great, but you don’t need it at all to work with dates in matplotlib…

    You’ll probably want to use the various functions in matplotlib.dates, plot_date to plot your values, imshow (and/or pcolor in some cases) to plot your specgrams of various sorts, and matplotlib.mlab.specgram to compute them.

    For your subplots, you’ll want to use the sharex kwarg when creating them, so that they all share the same x-axis. To disable the x-axis labels on some axes when using sharing an x-axis between the plots, you’ll need to use something like matplotlib.pyplot.setp(ax1.get_xticklabels(), visible=False). (It’s a slightly crude hack, but it’s the only way to only display x-axis labels on the bottom subplot when sharing the same x-axis between all subplots) To adjust the spacing between subplots, see subplots_adjust.

    Hope all that makes some sense… I’ll add a quick example of using all of that when I have time later today…

    Edit:
    So here’s a rough example of the idea. Some things (e.g. multicolored axis labels) shown in your example are rather difficult to do in matplotlib. (Not impossible, but I’ve skipped them here…)

    import datetime
    
    import numpy as np
    import matplotlib as mpl
    import matplotlib.pyplot as plt
    
    from matplotlib import mlab
    
    from mpl_toolkits.axes_grid1 import make_axes_locatable
    
    def main():
        #-- Make a series of dates
        start = datetime.datetime(2010,9,15,8,0)
        end = datetime.datetime(2010,9,15,18,0)
        delta = datetime.timedelta(seconds=1)
    
        # Note: "time" is now an array of floats, where 1.0 corresponds
        # to one day, and 0.0 corresponds to 1900 (I think...)
        # It's _not_ an array of datetime objects!
        time = mpl.dates.drange(start, end, delta)
    
        num = time.size
    
        #-- Generate some data
        x = brownian_noise(num) 
        y = brownian_noise(num)
        z = brownian_noise(num)
    
        plot(x, y, z, time)
        plt.show()
    
    def plot(x, y, z, time):
        fig = plt.figure()
    
        #-- Panel 1
        ax1 = fig.add_subplot(311)
        im, cbar = specgram(x, time, ax1, fig)
        ax1.set_ylabel('X Freq. (Hz)')
        ax1.set_title('Fake Analysis of Something')
    
        #-- Panel 2
        ax2 = fig.add_subplot(312, sharex=ax1)
        im, cbar = specgram(y, time, ax2, fig)
        ax2.set_ylabel('Y Freq. (Hz)')
    
        #-- Panel 3
        ax3 = fig.add_subplot(313, sharex=ax1)
        # Plot the 3 source datasets
        xline = ax3.plot_date(time, x, 'r-')
        yline = ax3.plot_date(time, y, 'b-')
        zline = ax3.plot_date(time, z, 'g-')
        ax3.set_ylabel(r'Units $(\mu \phi)$')
    
        # Make an invisible spacer...
        cax = make_legend_axes(ax3)
        plt.setp(cax, visible=False)
    
        # Make a legend
        ax3.legend((xline, yline, zline), ('X', 'Y', 'Z'), loc='center left', 
                bbox_to_anchor=(1.0, 0.5), frameon=False)
    
        # Set the labels to be rotated at 20 deg and aligned left to use less space
        plt.setp(ax3.get_xticklabels(), rotation=-20, horizontalalignment='left')
    
        # Remove space between subplots
        plt.subplots_adjust(hspace=0.0)
    
    def specgram(x, time, ax, fig):
        """Make and plot a log-scaled spectrogram"""
        dt = np.diff(time)[0] # In days...
        fs = dt * (3600 * 24) # Samples per second
    
        spec_img, freq, _ = mlab.specgram(x, Fs=fs, noverlap=200)
        t = np.linspace(time.min(), time.max(), spec_img.shape[1])
    
        # Log scaling for amplitude values
        spec_img = np.log10(spec_img)
    
        # Log scaling for frequency values (y-axis)
        ax.set_yscale('log')
    
        # Plot amplitudes
        im = ax.pcolormesh(t, freq, spec_img)
    
        # Add the colorbar in a seperate axis
        cax = make_legend_axes(ax)
        cbar = fig.colorbar(im, cax=cax, format=r'$10^{%0.1f}$')
        cbar.set_label('Amplitude', rotation=-90)
    
        ax.set_ylim([freq[1], freq.max()])
    
        # Hide x-axis tick labels
        plt.setp(ax.get_xticklabels(), visible=False)
    
        return im, cbar
    
    def make_legend_axes(ax):
        divider = make_axes_locatable(ax)
        legend_ax = divider.append_axes('right', 0.4, pad=0.2)
        return legend_ax
    
    def brownian_noise(num):
        x = np.random.random(num) - 0.5
        x = np.cumsum(x)
        return x
    
    
    if __name__ == '__main__':
        main()
    

    alt text

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to make a simple parser, for a pseudo code like language(kept rigid),
I wanted to make a option class, where you could load all preferences of
I wanted to make toggle buttons in my activity look something like the picture
I wanted to make a Java based web crawler for an experiment. I heard
I wanted to make a JOptionPane.showOptionDialog with some JTextArea and JLabel . The problem
I wanted to make my top left hand corner of a table rounded in
I wanted to make some simple file recovery software, where I want to try
I wanted to make a basic custom keypad for the iPhone , I did
I wanted to make an application that will take either the path of the
I wanted to make a function that populates a Grid in WPF with pictures.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.