Setting the origin of a 2DHistogram Plot in PlotPy

I have been working with the PlotPy library (not to be confused with Plotly) to create a Python Qt GUI to display a series of plots — one of which happens to be a 2D Histogram. Following their example with some modifications to the data, I was able to create a Histogram2DItem that displays 150,000 dots on a scatter plot that appear within the X values of 0.57-13.57 and the Y values of 1.59-15.46 (rounded to the nearest hundredth).

In order to generate this data, the following code is processed:

from numpy import array, concatenate, dot, random
#...

N = 150000
matrix = array([[2.0, 0.2], [3, 5.0]])
X_array_data_1 = random.normal(2, 0.3, size=(N, 2))
X_array_data_2 = random.normal(2, 0.3, size=(N, 2))
X = concatenate((X_array_data_1 + [0, 1.0], dot(X_array_data_2, matrix) + [-1, -1.0]))
column_1 = X[:,0]
column_2 = X[:,1]
combined_columns = X[:,0] + X[:,1]

# See below for the setup_scatterplot() definition.
self.setup_scatterplot(column_1, column_2, combined_columns)

In addition, I have set the BasePlot (which the Histogram2DItem is added into) so that it limits itself from 0.0 to 10.0 on both axes. The idea with setting the plot up this way was to make it so that the X value of 0 appeared on the far left of the graph and the Y value of 0 appeared on the bottom of the graph, setting a clearly-defined origin to the graph. What appears, instead, is the following histogram with an X-axis that begins at around -0.2 and a Y-axis begins at 1.8.

The setup_scatterplot() function (see below) then instantiates the necessary PlotPy items. Keep in mind that PlotPy is the successor to guiqwt, both of which are higher-level iterations of the Qwt library. This is important to understand, as Qwt functions and types have been considered while looking for potential solutions to this issue.

import numpy as np
from PySide6 import QtWidgets
from PySide6.QtWidgets import QVBoxLayout
from plotpy.items import Histogram2DItem
from plotpy.styles import Histogram2DParam
#...

def setup_scatterplot(self, x_axis, y_axis, z_axis):
    X = x_axis
    Y = y_axis
    Z = z_axis
    
    # NOTE: The PlotPy documentation uses the "make" function to create its Histogram.
    #       This, however, does not change the outcome on the graph.
    histogram2d_param = Histogram2DParam()
    histogram2d_param.label = "Markers"
    self.hist2d = Histogram2DItem(np.asarray(X), np.asarray(Y), histogram2d_param, Z=Z)
    
    self.scatter_plot_panel = QVBoxLayout()
    self.scatter_plot = BasePlot()
    self.scatter_plot.set_plot_limits(0.0, 10.0, 0.0, 10.0, 2, 0) # 2 is the X-axis and 0 is the Y-axis.
    self.scatter_plot.set_aspect_ratio(lock=True)
    self.scatter_plot.setAxisAutoScale(False) # This doesn't seem to fix auto-scaling at all.
    self.scatter_plot.add_item(self.hist2d)
    self.scatter_plot.replot() # Replotting or not, the graph does not seem to update.
    self.scatter_plot.set_axis_direction(0, False) # Sets the Y-axis to go from 0 on the bottom and up.
    self.scatter_plot_panel.addWidget(self.scatter_plot)

From what I have noticed: by itself, prior to adding the 2D histogram, the scatter_plot shows a graph that goes from 0 to 10 on the X- and Y-axes without issue. It is only after the .add_item(self.hist2d) operation where the maximum and minimum values of both axes are changed to how they appear in the image above.

For those more familiar with Qwt: the PlotPy BasePlot type inherits QwtPlot. The set_plot_limits() function in BasePlot calls upon another function in the BasePlot code called set_axis_limits(), which calls upon the QwtPlot function setAxisScale().

I have seen others state that fixing the X-axis length is as simple as disabling the auto-scaling and manually setting the axes with the .setAxisScale() function. As I eventually want to apply zooming+scrolling functionality to this histogram, I have also looked into setting the zoom range, resulting in my finding a comment about implementing the QwtPlotZoomer class, but this is not available to me.

If anyone knows anything about PlotPy/Qwt and how to set limits on the plot after applying a histogram to it, any help at all would be greatly appreciated!

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật