class CompositeModel(models.Model): # Plot piecewise line line_plot = MatplotlibFigureField(figure='plot_line', verbose_name='Line', silent=True) # Plot sine function sine_plot = MatplotlibFigureField(figure='plot_sine', verbose_name='Sine', silent=True) # Imshow demo imshow_demo = MatplotlibFigureField(figure='image_plot', verbose_name='Imshow demo', silent=True) # Pass arguments to plot with_args = MatplotlibFigureField(figure='plot_with_args', verbose_name="Args passed", silent=True, plt_args=([1, 4, 2], [5, 2, 1]), help_text="Arguments are passed to the plot " "using `plt_args` keyword." ) # Countour plot as svg countour_plot = MatplotlibFigureField(figure='countour_plot', verbose_name="Contour plot", silent=True, plt_kwargs={"custom_title": "Custom figure title goes here..." } )
class MyModelWithFigure(models.Model): # ... other fields # figures.py should be in the same directory where models.py is placed. # see ./django_matplotlib/figures.py for example. fig = MatplotlibFigureField(figure='test_figure', verbose_name='figure', silent=True)
def build_env(request): sample_model = create_model('SampleModel%s' % ind, fields={'figure': MatplotlibFigureField(**kw)}, module='django_matplotlib', app_label='django_matplotlib') class SampleForm(forms.ModelForm): class Meta: model = sample_model fields = '__all__' response = test_view(request, SampleForm()) return response
class DataPlot(models.Model): figure = MatplotlibFigureField(figure='my_figure')
class MyModel(models.Model): figures = MatplotlibFigureField(figure='my_figure')
name=models.CharField(max_length=100) title=models.CharField(max_length=3,choices=TITLE_CHOICES) birth_date=models.DateField(blank=True,null=True) def _str_(self): return self.name class Book(forms.Model): nom=models.CharField(max_length=100) authors=models.ManyToManyField(Author) class MyModel(models.Model): figures = MatplotlibFigureField(figure='my_figure') # Plot piecewise line line_plot = MatplotlibFigureField(figure='plot_line', verbose_name='Line', silent=True) # Plot sine function sine_plot = MatplotlibFigureField(figure='plot_sine', verbose_name='Sine', silent=True) # Imshow demo imshow_demo = MatplotlibFigureField(figure='image_plot', verbose_name='Imshow demo', silent=True) # Pass arguments to plot with_args = MatplotlibFigureField(figure='plot_with_args', verbose_name="Args passed", silent=True, plt_args=([1, 4, 2], [5, 2, 1]), help_text="Arguments are passed to the plot " "using `plt_args` keyword." ) # Countour plot as svg
class Signal(models.Model): line_plot = MatplotlibFigureField(figure='plot_line', verbose_name='Line', silent=True)