小编Cam*_*mon的帖子

Matplotlib崩溃tkinter应用程序

我正在构建一个将matplotlib图形嵌入GUI的应用程序.问题是,一旦我将matplotlib中的任何内容添加到我的代码中,我的应用程序就会崩溃(导入除外,这些工作正常).在我的课,会出现问题Solver_Apptk.Tk.__init__(self, *args, **kwargs).当我运行代码时,我收到一个巨大的错误,应用程序崩溃.这是我的一些代码:

import tkinter as tk
from tkinter import ttk

import matplotlib
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure

# Setting up figures for integration in GUI:
fig_3D = plt.figure()
fig_2D = plt.figure()
a_3D = fig_3D.add_subplot(111, projection="3d")
a_2D = fig_2D.add_subplot(111)
a_3D.plot_wireframe([1, 2, 3, 4, 5], [1, 3, 7, 6, 4], [1, 2, 3, 4, 5], color="blue")

class Solver_App(tk.Tk, ttk.Frame):

    def __init__(self, *args, **kwargs): …
Run Code Online (Sandbox Code Playgroud)

python user-interface tkinter matplotlib ttk

25
推荐指数
1
解决办法
1万
查看次数

iOS图表反转X轴方向

我有一个使用Daniel Gindi iOS图表构建的条形图.它代表一段时间内的历史数据.我遇到的问题是数据是从左到右(新数据 - >旧数据)绘制的.我需要将它绘制为从右到左(旧数据 - >新数据).我知道我可以颠倒我输入数据的顺序BarChartData,但后来我的图表问题仍然是左对齐.它需要正确对齐.我在这里讨论了讨论反转x轴的问题以及如何解决它(目前不是框架的一个包含特性),但是我无法弄清楚实际需要做什么.以下是我需要的例子:

这就是我的图表目前的样子:

在此输入图像描述

这就是我需要的样子:

在此输入图像描述

我的问题

有没有办法颠倒x轴?

要么

有没有办法正确对齐图表?

以下是我的一些代码并尝试解决此问题:

class ViewController: UIViewController {

    @IBOutlet weak var barChartView: BarChartView!

    //...

    func plotChart() {

        // Create history data
        //...

        barChartView.data = chartData  // 'chartData' is the BarChartData() containing all of the history information

        // No efect
        barChartView.legend.direction = .RightToLeft

        // Chart breaks
        barChartView.leftAxis.axisMinValue = 30
        barChartView.leftAxis.axisMaxValue = 0

        // Breaks the ability to zoom
        barChartView.setVisibleXRangeMinimum(CGFloat(40))
        barChartView.setVisibleXRangeMaximum(CGFloat(1))

    }

}
Run Code Online (Sandbox Code Playgroud)

charts ios swift ios-charts

6
推荐指数
1
解决办法
1338
查看次数

删除单元格时 UITableViewCell 中的 UIVisualEffectView 会中断

我创建了一个UITableViewController,每个单元格都使用应用了模糊效果UIVisualEffectViewUITabBarViewController我还有一个在表格视图链接到的背景中创建的模糊背景。应用于每个单元格的额外模糊效果为我正在设计的 UI 增添了漂亮的感觉,并且它在大多数情况下都有效。

问题

一切正常,直到我从表中删除一个项目。这样做会导致整个表视图看起来已损坏。删除动画完成后一切恢复正常。

我尝试应用过UIVisualEffectView孔代码和故事板,无论哪种方式,问题都是一致的。使用代码时,我在这里应用效果如下:

// 'cell' is the cell being configured in tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
let visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light))
visualEffectView.frame = cell.bounds
cell.insertSubview(visualEffectView, atIndex: 0)
Run Code Online (Sandbox Code Playgroud)

注意:经过更多测试后,我已经缩小了问题范围。通过情节提要或在代码中使用 将单元格设置为清晰颜色时cell.backgroundColor = UIColor.clearColor(),会出现损坏的动画。事实上,它对任何具有一定透明度或完全透明度的颜色都执行此操作。当没有透明度时,问题就会停止,但背景UITabBarController将不再可见。

我的问题

如何修复损坏的动画,同时保持相似/相同的外观?

如果你想看看我如何将模糊添加到UITableViewController,这里是:

class MainTabBarViewController: UITabBarController, UITabBarControllerDelegate {

    var imageView: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()
        self.delegate = self

        imageView = UIImageView(image: UIImage(named: "Sunset"))
        imageView.frame = …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift uivisualeffectview

5
推荐指数
0
解决办法
394
查看次数

更改iOS图表中组合图表的绘制顺序

我正在使用Danielgindi的图表框架将数据呈现给用户。我想要做的是使用来显示两个图表CombinedChartView。这两个图表分别是BarChartDataSetLineChartDataSet。我可以成功显示两组数据,但是似乎无法控制绘图顺序。条形图BarChartDataSet始终位于的后面LineChartDataSet。我希望此订单可以颠倒并LineChartDataSet在后面(包括我所应用的所有填充)。

我的问题

如何更改绘制顺序,CombinedChartView使折线图在背面而不是正面?

这是我的代码:

// barDataEntries and lineDataEntries are generated in a different section and are not relevant to this question. Any data will do.
// barDataEntries is of type [BarChartDataEntry]()
// lineDataEntries is of type [ChartDataEntry]()
let barChartSet = BarChartDataSet(yVals: barDataEntries, label: "The Bars")
let lineChartSet = LineChartDataSet(yVals: lineDataEntries, label: "The Line")
barChartSet.barShadowColor = UIColor(red: 1, green: 0, blue: 0, alpha: 0)  // …
Run Code Online (Sandbox Code Playgroud)

charts drawing ios swift ios-charts

1
推荐指数
1
解决办法
1229
查看次数