How to add two plots to a subplot?

Jan Erst

So currently I'm creating a plot which consists of the code:

plt.imshow(prob_mesh[:, 1].reshape((1000, 1000)),
               extent=(-4, 4, -4, 4), origin='lower')
plt.scatter(predicting_classes_pos_inputs[:, 0], predicting_classes_pos_inputs[:, 1], marker='o', c='w',
            edgecolor='k')

Notice that both these two are supposed to be in the the same plot, now I would like to add:

plt.imshow(prob_mesh[:, 0].reshape((1000, 1000)),
           extent=(-4, 4, -4, 4), origin='lower')
plt.scatter(predicting_classes_neg_inputs[:, 0], predicting_classes_neg_inputs[:, 1], marker='o', c='w',
            edgecolor='k')

That is, I want these two be plotted in the same plot, but next to each other, hope you understand, how would one implement something like this?

Sheldore

IIUC, you want something like the following. Below is one working answer for you using some fake data. Just replace it with your actual data and see if it served your need.

import matplotlib.pyplot as plt
import numpy as np

prob_mesh = np.random.randint(-4, 4, (100, 100))

f, (ax1, ax2) = plt.subplots(1, 2)

ax1.imshow(prob_mesh[:, 1].reshape((10, 10)),extent=(-4, 4, -4, 4), origin='lower')
ax1.scatter(prob_mesh[:, 1], prob_mesh[:, 0], marker='o', c='w',edgecolor='k')

ax2.imshow(prob_mesh[:, 1].reshape((10, 10)),extent=(-4, 4, -4, 4), origin='lower')
ax2.scatter(prob_mesh[:, 1], prob_mesh[:, 0], marker='o', c='w',edgecolor='k')

enter image description here

Эта статья взята из Интернета, укажите источник при перепечатке.

Если есть какие-либо нарушения, пожалуйста, свяжитесь с[email protected] Удалить.

Отредактировано в
0

я говорю два предложения

0обзор
Войти в системуУчаствуйте в комментариях

Статьи по теме

Plotly: How to add axis layouts into a subplot?

How to add multiple bar graph in subplot in Matplotlib

Single legend for Plotly subplot for line plots created from two data frames in R

How to subplot two alternate x scales and two alternate y scales for more than one subplot?

Julia - Displaying several plots in the same plot (not subplot)

Как разделить оси после добавления подзаголовков через add_subplot?

Использование add_subplot для нескольких графиков на фигуре

Понимание разницы между графиками subplot и add_subplot (scatter) в matplotlib

How to print two or more plots in one graph using C and gnuplot

Python subplot 3 plots in 2x2 matrix (pyramid)

Add Empty Subplot With No Axis Ticks/Labels for Text as Subplot in Matplotlib

Каковы различия между add_axes и add_subplot?

Невозможно объединить графики с помощью команды subplot

Отображение нескольких изображений в сетке с помощью subplot ()

Ошибка matplotlib add_subplot и change_geometry?

Как работает .add_subplot (nrows, ncols, index)?

Что означает аргумент в Matplotlib на fig.add_subplot (111)?

fig.gca () против fig.add_subplot ()

Как уменьшить масштаб коробки морского дна с помощью plt.figure и add_subplot?

How to add two column in pandas

How to add two timedate variables?

How to add two arrays in numpy

how to combine two or more pandas dataframes with different length time-series for matplotlib plots?

How to create 2 plots side by side when there are two categories in your dataframe?

How to dynamically add plots (lines/traces) from different sources/datasets to a plotly object in R (Shiny)?

How to separate plots better?

Почему функция tight_layout matplotlib.gridspec некорректно работает с pyplot.subplot, тогда как с fig.add_subplot?

How to create a subplot for each group of a pandas column

How to change the color of lines within a subplot?

TOP список

  1. 1

    Распределение Рэлея Curve_fit на Python

  2. 2

    В типе Observable <unknown> отсутствуют следующие свойства из типа Promise <any>.

  3. 3

    Merging legends in plotly subplot

  4. 4

    TypeError: store.getState não é uma função. (Em 'store.getState ()', 'store.getState' é indefinido, como posso resolver esse problema?

  5. 5

    ContentDialog.showAsync в универсальном оконном приложении Win 10

  6. 6

    PayPal REST API возвращает INVALID_CURRENCY_AMOUNT_FORMAT

  7. 7

    Невозможно отобразить данные модели загрузки Spring в Thymeleaf

  8. 8

    FormsAuthentication.SignOut () не работает после изменения CookieDomain

  9. 9

    Перебирайте несколько столбцов в фрейме данных Panda и находите уникальные значения подсчета

  10. 10

    Does addListener in JavaFX get garbage collected when the ChangeListener is typed as a lambda?

  11. 11

    Définition de la valeur par défaut dans le dictionnaire Python si la clé est manquante

  12. 12

    How to click an array of links in puppeteer?

  13. 13

    Cannot find reference System

  14. 14

    Android Включение / выключение вспышки камеры программно с помощью Camera2

  15. 15

    Как добавить Swagger в веб-API с поддержкой OData, работающий на ASP.NET Core 3.1

  16. 16

    How to set windows.form's start position to bottom?

  17. 17

    Добавить URL-адрес скрипта в очередь: поместить переменную в URL-адрес

  18. 18

    Разделить набор на несколько наборов Scala

  19. 19

    Интеграция Jenkins + Jfrog через плагины - в опубликованном банке добавлена метка времени (дата)

  20. 20

    Unable to open a new window from a method

  21. 21

    Запуск sqlplus в фоновом режиме в Unix

популярныйтег

файл