@@ -1857,6 +1857,62 @@ inline void legend(const std::map<std::string, std::string>& keywords)
18571857 Py_DECREF (res);
18581858}
18591859
1860+ template <typename Numeric>
1861+ inline void set_aspect (Numeric ratio)
1862+ {
1863+ detail::_interpreter::get ();
1864+
1865+ PyObject* args = PyTuple_New (1 );
1866+ PyTuple_SetItem (args, 0 , PyFloat_FromDouble (ratio));
1867+ PyObject* kwargs = PyDict_New ();
1868+
1869+ PyObject *ax =
1870+ PyObject_CallObject (detail::_interpreter::get ().s_python_function_gca ,
1871+ detail::_interpreter::get ().s_python_empty_tuple );
1872+ if (!ax) throw std::runtime_error (" Call to gca() failed." );
1873+ Py_INCREF (ax);
1874+
1875+ PyObject *set_aspect = PyObject_GetAttrString (ax, " set_aspect" );
1876+ if (!set_aspect) throw std::runtime_error (" Attribute set_aspect not found." );
1877+ Py_INCREF (set_aspect);
1878+
1879+ PyObject *res = PyObject_Call (set_aspect, args, kwargs);
1880+ if (!res) throw std::runtime_error (" Call to set_aspect() failed." );
1881+ Py_DECREF (set_aspect);
1882+
1883+ Py_DECREF (ax);
1884+ Py_DECREF (args);
1885+ Py_DECREF (kwargs);
1886+ }
1887+
1888+ inline void set_aspect_equal ()
1889+ {
1890+ // expect ratio == "equal". Leaving error handling to matplotlib.
1891+ detail::_interpreter::get ();
1892+
1893+ PyObject* args = PyTuple_New (1 );
1894+ PyTuple_SetItem (args, 0 , PyString_FromString (" equal" ));
1895+ PyObject* kwargs = PyDict_New ();
1896+
1897+ PyObject *ax =
1898+ PyObject_CallObject (detail::_interpreter::get ().s_python_function_gca ,
1899+ detail::_interpreter::get ().s_python_empty_tuple );
1900+ if (!ax) throw std::runtime_error (" Call to gca() failed." );
1901+ Py_INCREF (ax);
1902+
1903+ PyObject *set_aspect = PyObject_GetAttrString (ax, " set_aspect" );
1904+ if (!set_aspect) throw std::runtime_error (" Attribute set_aspect not found." );
1905+ Py_INCREF (set_aspect);
1906+
1907+ PyObject *res = PyObject_Call (set_aspect, args, kwargs);
1908+ if (!res) throw std::runtime_error (" Call to set_aspect() failed." );
1909+ Py_DECREF (set_aspect);
1910+
1911+ Py_DECREF (ax);
1912+ Py_DECREF (args);
1913+ Py_DECREF (kwargs);
1914+ }
1915+
18601916template <typename Numeric>
18611917void ylim (Numeric left, Numeric right)
18621918{
0 commit comments