diff --git a/tree/dataframe/src/RDFHistoModels.cxx b/tree/dataframe/src/RDFHistoModels.cxx
index 519c30fc101023337569e95471da584a519ea39a..d8bacbfa0a46783a8185f466e325ee8bb7f9dd43 100644
--- a/tree/dataframe/src/RDFHistoModels.cxx
+++ b/tree/dataframe/src/RDFHistoModels.cxx
@@ -272,6 +272,8 @@ TProfile2DModel::TProfile2DModel(const ::TProfile2D &h)
      fXUp(h.GetXaxis()->GetXmax()), fNbinsY(h.GetNbinsY()), fYLow(h.GetYaxis()->GetXmin()),
      fYUp(h.GetYaxis()->GetXmax()), fZLow(h.GetZmin()), fZUp(h.GetZmax()), fOption(h.GetErrorOption())
 {
+   SetAxisProperties(h.GetXaxis(), fXLow, fXUp, fBinXEdges);
+   SetAxisProperties(h.GetYaxis(), fYLow, fYUp, fBinYEdges);
 }
 TProfile2DModel::TProfile2DModel(const char *name, const char *title, int nbinsx, double xlow, double xup, int nbinsy,
                                  double ylow, double yup, const char *option)
@@ -311,9 +313,32 @@ TProfile2DModel::TProfile2DModel(const char *name, const char *title, int nbinsx
 
 std::shared_ptr<::TProfile2D> TProfile2DModel::GetProfile() const
 {
-   auto prof =
-      std::make_shared<::TProfile2D>(fName, fTitle, fNbinsX, fXLow, fXUp, fNbinsY, fYLow, fYUp, fZLow, fZUp, fOption);
-   prof->SetDirectory(nullptr); // lifetime is managed by the shared_ptr, detach from ROOT's memory management
+   auto xEdgesEmpty = fBinXEdges.empty();
+   auto yEdgesEmpty = fBinYEdges.empty();
+   std::shared_ptr<::TProfile2D> prof;
+   if (xEdgesEmpty && yEdgesEmpty) {
+      prof = std::make_shared<::TProfile2D>(fName, fTitle,
+                                            fNbinsX, fXLow, fXUp,
+                                            fNbinsY, fYLow, fYUp,
+                                            fZLow, fZUp, fOption);
+   } else if (!xEdgesEmpty && yEdgesEmpty) {
+      prof = std::make_shared<::TProfile2D>(fName, fTitle,
+                                            fNbinsX, fBinXEdges.data(),
+                                            fNbinsY, fYLow, fYUp,
+                                            fOption);
+   } else if (xEdgesEmpty && !yEdgesEmpty) {
+      prof = std::make_shared<::TProfile2D>(fName, fTitle,
+                                            fNbinsX, fXLow, fXUp,
+                                            fNbinsY, fBinYEdges.data(),
+                                            fOption);
+   } else {
+      prof = std::make_shared<::TProfile2D>(fName, fTitle,
+                                            fNbinsX, fBinXEdges.data(),
+                                            fNbinsY, fBinYEdges.data(),
+                                            fOption);
+   }
+
+   prof->SetDirectory(nullptr); // object's lifetime is managed by the shared_ptr, detach it from ROOT's memory management
    return prof;
 }