22709

add boxplot to other graph in python

<img src="https://i.stack.imgur.com/Sj1Ju.png" alt="enter image description here">

These two graphs have exactly the same x axis value of each point, is it possible to display the box whisker on top of the first graph?

I tried this:

fig1 = plt.figure() ax = fig1.add_subplot(211) ax.set_xscale('log') ax.plot(x7,y7,'c+-') ax.plot(x8,y8,'m+-') ax.plot(x9,y9,'g+-') ax.boxplot(dataset) xtickNames = plt.setp(ax, xticklabels=boxx) plt.setp(xtickNames)

The results only display the box whisker graph without the other three lines, so, I tried this instead:

fig1 = plt.figure() ax = fig1.add_subplot(211) ax2 = fig1.add_subplot(212) ax.set_xscale('log') ax.plot(x7,y7,'c+-') ax.plot(x8,y8,'m+-') ax.plot(x9,y9,'g+-') ax2.set_xscale('log') ax2.boxplot(dataset) xtickNames = plt.setp(ax2, xticklabels=boxx) plt.setp(xtickNames)

But I want them to be shown in the same graph, is that possible?

Answer1:

If you want two graphs with comparable X and Y ranges to appear one on top of the other, you can try "Hold". For example:

import pylab pylab.plot([1,2,3,4],[4,3,2,1]) pylab.hold(True) pylab.plot([1,2,3,4],[1,2,3,4])

Recommend

  • Draw a rectangle made with printf function, consisted of inner frames [closed]
  • 8-queen problem using Dynamic programming
  • Basic Python function and outputs
  • What is the purpose of the ROI layer in a Fast R-CNN?
  • Plotting lines with pyplot when button clicked with values from tkinter spinbox
  • Can I set a cap on costs in Windows Azure?
  • audio codec dequeueInputBuffer returns -1 on device
  • Maximizing linear objective subject to quadratic constraints
  • multi-line pattern matching in python
  • Converting Number format
  • Disassembling: Why a jmp that leads nowhere?
  • Postgresql - Renumber columns
  • Source name when writing to event viewer C#
  • Long running script in Google Cloud
  • R - corrplot correlation matrix division
  • why do we “pack” the sequences in pytorch?
  • C++: Linking files with GCC compiler
  • Change the background colour of a projected Matplotlib axis
  • Python 3d Pyramid
  • Getting different result each time I run a linear regression using scikit
  • Changing axis without changing data (Python)
  • Embedding a live updating matplotlib graph in wxpython
  • Why do i get infinite loop
  • Invalid rgba arg “#” in matplotlib
  • Proper Mutational scale value in matplotlib
  • Label Areas in Python Matplotlib stackplot
  • matplotlib's colormap
  • How to calculate variance of an image patch with vectorization
  • How to deal with SpiderWebPlot in JFreeChart?
  • Merge the values of multiple elements and take the average of the attribute field
  • Geom_jitter colour based on values
  • cell spacing in div table
  • XSLT foreach repeating nodes to flat
  • How to create a 2D image by rotating 1D vector of numbers around its center element?
  • Thread 1: EXC_BAD_ACCESS (code =1 address = 0x0)
  • Can a Chrome extension content script make an jQuery AJAX request for an html file that is itself a
  • Upload files with Ajax and Jquery
  • AngularJs get employee from factory
  • Proper way to use connect-multiparty with express.js?
  • Memory offsets in inline assembly