I am writing a program to plot orbits around the Earth. The orbits are represented by lists of x and y coordinates and plotted with the plot()
function.
Now I would like to have Earth shown as a filled circle with the correct radius around origin. I tried to use the MatLab function rectangle()
but get error messages saying that there is no suck attribute.
I have read in other sources that using pyplot
might cause unexpected behavior and would like to achieve this without using that library.
In short, I would like a filled circle with radius r around the * in this figure.
How can I implement this function in my MWE:
import sys
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
from matplotlib.backends.backend_qt4agg import NavigationToolbar2QT as NavigationToolbar
from matplotlib.figure import Figure
from PyQt4 import QtCore, QtGui, uic
qtCreatorMain = "GUI.ui"
Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorMain)
class MainGUI(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainGUI, self).__init__(parent)
self.setupUi(self)
#### Lots of other code goes here ####
# PlotView
self.figure = Figure(tight_layout=True)
self.canvas = FigureCanvas(self.figure)
self.toolbar = NavigationToolbar(self.canvas, self)
self.plotLayout.addWidget(self.toolbar)
self.plotLayout.addWidget(self.canvas)
self.graph = self.figure.add_subplot(111)
self.graph.axis('equal')
self.graph.plot([-3, -2, -1, 0, 1, 2, 3], [0, -1, 4, 2, 0, -3, -5])
self.graph.plot(0, 0, '*')
### Even more code goes here ####
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
window = MainGUI()
window.show()
sys.exit(app.exec_())
GUI.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>MainWindow</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string><html><head/><body><p align="center"><span style=" font-size:20pt; font-weight:600;">Lots of stuff goes</span></p><p align="center"><span style=" font-size:20pt; font-weight:600;">in this part</span></p></body></html></string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="plotLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="sizeConstraint">
<enum>QLayout::SetDefaultConstraint</enum>
</property>
</layout>
</item>
</layout>
<zorder>verticalLayoutWidget</zorder>
<zorder>frame</zorder>
<zorder>label</zorder>
</widget>
<widget class="QMenuBar" name="menubar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>27</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusbar"/>
</widget>
<resources/>
<connections/>
</ui>