Skip to content

Commit

Permalink
Plotting method now takes a function as an argument.
Browse files Browse the repository at this point in the history
  • Loading branch information
heshamelsawaf committed Apr 22, 2017
1 parent 9a6b723 commit 69ac980
Show file tree
Hide file tree
Showing 7 changed files with 381 additions and 292 deletions.
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,50 @@
.DS_Store
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
/out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
12 changes: 12 additions & 0 deletions .idea/Root-Finder.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 23 additions & 12 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,49 @@
import numpy as np
from PyQt4 import QtGui
from PyQt4.uic import loadUiType

from matplotlib.figure import Figure
from matplotlib.backends.backend_qt4agg import (
FigureCanvasQTAgg as FigureCanvas,
NavigationToolbar2QT as NavigationToolbar)
from matplotlib.figure import Figure
from sympy import *

Ui_MainWindow, QMainWindow = loadUiType('window.ui')


def f(x):
return np.sin(x);


class Main(QMainWindow, Ui_MainWindow):
def __init__(self, ):
super(Main, self).__init__()
self.setupUi(self)
self.fig1 = Figure()

def addmpl(self, fig):
def drawFig(self, fig):
self.canvas = FigureCanvas(fig)
self.mplvl.addWidget(self.canvas)
self.canvas.draw()
self.toolbar = NavigationToolbar(self.canvas,
self.mplwindow, coordinates=True)
self.mplvl.addWidget(self.toolbar)

if __name__ == '__main__':
import sys
from PyQt4 import QtGui
import numpy as np
def plot(self, y):
plt = self.fig1.add_subplot(111)
xs = np.arange(-100.0, 100.0, 0.1)
plt.plot(xs, y(xs))
plt.axis([-6, 6, -1, 1])
self.drawFig(self.fig1)


if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
main = Main()
main.show()

#figure example
fig1 = Figure()
ax1f1 = fig1.add_subplot(111)
ax1f1.plot(np.random.rand(5))
main.addmpl(fig1)
# figure example
x = Symbol('x')
y = sin(x)
main.plot(lambdify(x, y.diff(x), 'numpy'))

sys.exit(app.exec_())
Loading

0 comments on commit 69ac980

Please sign in to comment.