matplotlib-animation 相关问题


AnimationSet 未按预期执行顺序动画

如果我手动执行多个连续动画。它按预期工作。这是我的可行代码 扩展.xml 如果我手动执行多个连续动画。它按预期工作。这是我的可行代码 scale_up.xml <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.0" android:fromYScale="1.0" android:toXScale="1.1" android:toYScale="1.1" android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" android:interpolator="@android:anim/decelerate_interpolator" android:duration="@android:integer/config_shortAnimTime" /> scale_down.xml <?xml version="1.0" encoding="utf-8"?> <scale xmlns:android="http://schemas.android.com/apk/res/android" android:fromXScale="1.1" android:fromYScale="1.1" android:toXScale="1.0" android:toYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:fillAfter="true" android:interpolator="@android:anim/decelerate_interpolator" android:duration="@android:integer/config_shortAnimTime" /> 手动执行连续动画 public void startAnimation(Button button) { // Define the scale up animation Animation scaleUpAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_up); // Define the scale down animation Animation scaleDownAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_down); scaleUpAnimation.setAnimationListener(new Animation.AnimationListener() { @Override public void onAnimationStart(Animation animation) { } @Override public void onAnimationEnd(Animation animation) { button.startAnimation(scaleDownAnimation); } @Override public void onAnimationRepeat(Animation animation) { } }); button.startAnimation(scaleUpAnimation); } 结果 但是,如果我尝试使用 AnimationSet 替换上述代码,动画结果就会损坏。 public void startAnimation(Button button) { // Define the scale up animation Animation scaleUpAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_up); // Define the scale down animation Animation scaleDownAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_down); // Create an AnimationSet to combine both animations // (It makes no difference whether I am using true or false) AnimationSet animationSet = new AnimationSet(true); animationSet.addAnimation(scaleUpAnimation); animationSet.addAnimation(scaleDownAnimation); // Apply the animation to the button button.startAnimation(animationSet); } 使用AnimationSet的结果(动画不流畅) 我可以知道为什么AnimationSet不起作用吗?谢谢。 我们需要使用setStartOffset来延迟第二个动画的执行。这是解决上述问题的完整代码片段。 public void startAnimation(Button button) { int config_shortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime); // Define the scale up animation ScaleAnimation scaleUpAnimation = new ScaleAnimation( 1f, 1.02f, 1f, 1.02f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ); scaleUpAnimation.setInterpolator(new DecelerateInterpolator()); scaleUpAnimation.setDuration(config_shortAnimTime); scaleUpAnimation.setFillAfter(true); // Define the scale down animation ScaleAnimation scaleDownAnimation = new ScaleAnimation( 1.02f, 1f, 1.02f, 1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f ); scaleDownAnimation.setInterpolator(new AccelerateInterpolator()); scaleDownAnimation.setDuration(config_shortAnimTime); scaleDownAnimation.setFillAfter(true); scaleDownAnimation.setStartOffset(scaleUpAnimation.getDuration()); // Create an AnimationSet to combine both animations AnimationSet animationSet = new AnimationSet(false); animationSet.addAnimation(scaleUpAnimation); animationSet.addAnimation(scaleDownAnimation); // Apply the animation to the button button.startAnimation(animationSet); }


python matplotlib 透明热图颜色条

如何实现这样的python matplotlib heatmap colorbar? plt.imshow(a,aspect='auto', cmap=plt.cm.gist_rainbow_r) plt.colorbar()


Matplotlib 图例用颜色映射?

总的来说,我对 matplotlib 真的很困惑。我通常只使用 import matplotlib.pyplot as plt。 然后执行 plt.figure()、plt.scatter()、plt.xlabel()、plt.show() 等操作。 但后来我


pip install tensorflow 对我不起作用

在 Windows 10 上的 VSCode 中使用新的 venv 并想要安装 matplotlib 和张量流 matplotlib 安装成功,但是张量流也没有尝试使用特定版本,但确实...


Matplotlib:从 fill_ Between 导出的阴影区域有白色边框

我绘制了一些训练曲线,其中阴影区域代表标准误差。阴影区域是通过Matplotlib中的fill_ Between方法实现的。然而,导出的 .eps 图...


如何在reportlab画布中绘制matplotlib图形?

我想使用方法drawImage将使用matplotlib生成的图形添加到reportlab画布中,而不必先将图形保存到硬盘驱动器。 我的问题与以下内容有关: 是...


将 Sphinx doctest 与包含 Matplotlib 示例的文档字符串结合使用

下面所示的函数使用 Matplotlib 显示线图。该函数的文档字符串包含使用该函数与数字列表的示例。我正在使用 Sphinx make html 命令...


使用 matplotlib 在 x 轴下方等距离对齐多个标签

我正在尝试使用 matplotlib 在 x 轴下方添加一些标签。我有 5-6 个标签,我想将它们绘制在 x 轴下方。因此,这些标签的文本会有所不同,只需一个设置即可...


使用全局变量(动画类)时,matplotlib 中的动画函数被阻止

所以,我有问题。我需要对 CALP(级联自适应线性预测器)错误进行动画处理。我正在使用 liber matplotlib (动画类)来解决我的任务,但是当我尝试计算新系数时


仅在页面底部添加边距

我有一个始终固定在视图底部的 cookie 部分。 啦啦啦啦 我有一个始终固定在视图底部的 cookie 部分。 <section id="cookie-section"> <span id="cookie-text">Bla bla bla</span> </section> #cookie-section { min-height: 50px; width: 100%; position: fixed; display: flex; bottom: 0; background-color: rgba(38, 38, 38, 0.9); } 但是当你滚动并到达页面底部时,我想为其添加 50px 的 margin-bottom 。我该怎么做? 当你只是添加 margin-bottom: 50px; 到它时,它已经在开始时获得了我不想要的边距。仅当您滚动到达页面底部时。 可以使用滚动驱动动画,但支持还不好。 您可以使用 Google Chrome 测试以下内容 #cookie-section { min-height: 50px; inset: auto 0 0; position: fixed; display: flex; background-color: rgba(38, 38, 38, 0.9); color: #fff; animation: margin 2s; animation-timeline: scroll(root) } @keyframes margin { 0%,90% {margin-bottom:0;} 100% {margin-bottom:50px;} } body { min-height: 300vh; } <section id="cookie-section"> <span id="cookie-text">Bla bla bla</span> </section>


如何从Python中的matplotlib饼图获取颜色映射?

来自 pandas 关于从数据框创建饼图的文档: 我有以下代码: df = pd.DataFrame({'质量': [0.330, 4.87 , 5.97], ‘半径’: [2439.7, 6051.8, 6378.1]}...


在Python中修改xarray图图例

我刚开始使用 xarray 的绘图功能,我通常使用 matplotlib。 我正在尝试移动 xarray.plot.scatter 创建的图例。能够删除图例也很酷


如何设置轴限制

我需要帮助设置 matplotlib 上 y 轴的限制。这是我尝试过的代码,但没有成功。 将 matplotlib.pyplot 导入为 plt plt.figure(1, Figsize = (8.5,11)) plt.suptitle('情节标题...


类中的 Matplotlib 事件处理

有人可以解释一下吗? 该代码应该在按下鼠标按钮时打印出事件详细信息。如果我将button_press_event插槽连接到on_button_press(在...


缓存或重用cartopy功能

我正在使用 Cartopy 在多个 Matplotlib 子图中显示 GSHHSFeature 海岸线,并在其上叠加不同的数据。 将 matplotlib.pyplot 导入为 plt 将 cartopy.crs 导入为 ccrs 进口cartopy。


matplotlib 散点图图例不依赖于点的颜色

我想让散点图的图例不依赖于点的颜色。简单的例子如下: 将 matplotlib.pyplot 导入为 plt 将 numpy 导入为 np 将 pandas 导入为 pd 假数据...


在 Matplotlib 中标记步骤图

下面是一个代码,其中绘制了正弦波并在其顶部添加了阶跃波: 将 numpy 导入为 np 将 matplotlib.pyplot 导入为 plt # 正弦波参数 A = 5 # 增加幅度 f = 1 # 弗...


如何在pytest中抑制第三方日志

我们刚刚从nose切换到pytest,似乎没有一个选项可以抑制第三方日志记录。在鼻子配置中,我们有以下行: 日志过滤器=-matplotlib,-chardet。


如何将3D直方图转换为热图

我想知道是否有办法将 3D 直方图从 matplotlib 映射到颜色热图? 例如我有一个 3D 直方图 如何将其转换为热图,其中高度显示为颜色...


使用 matplotlib 添加垂直线

我的目标是首先创建两个图(我正确创建的),每个图代表市场上仍然未平仓的看跌期权和看涨期权数量的 CDF。 对于每个情节,我还想绘制


Matplotlib 在原始轴标签顶部从双轴绘制标签

我有一个问题,因为我使用左 y 轴绘制 7 个移动平均值(p1,数据帧)的图。在右侧 y 轴上,我绘制了 MA 的数据(pidx,也是数据帧)。时间到了-


Matplotlib 动画,要么运行缓慢并重新绘制颜色条,要么缺少绘图

我正在尝试通过加载每帧的 numpy 数组来对之前保存的数据进行动画处理。 我的代码如下: 图, ax = plt.subplots(1, 1, constrained_layout = False) def 例程(...


如何将Legend Matplotlib TKinter

我正在尝试在图形中创建图例,但当我使用 legend() 时它不起作用。我不知道还能做什么。我看到了很多关于它的信息,我也在做同样的事情,但它一直不起作用......


在 matplotlib 中使用 dict 值作为 xticks

我创建了一个有5个不同时间点的折线图,每个时间点包含6个不同的值。为了避免重叠误差线,我为每个时间点的每个值创建了一个偏移量,并且......


用 pandas 在空列表中追加项目

我正在尝试使用 Pandas 创建一个过滤数据框,并将其发送到使用 matplotlib 按条件分割的屏幕,但是当我尝试将项目添加到空列表中时,该列表不会按条件过滤...


使用seaborn绘制随时间变化的pH值,大约有5000个点

我正在尝试通过在工作中使用数据集来了解有关 Pandas/Matplotlib/Seaborn 的更多信息。我想用seaborn图表来自动化报告,当然,这对ba来说可能有点过分了......


导航工具栏平移和缩放按钮/图标在 matplotlib 中处于活动状态时不会突出显示背景

我使用 PySide6 和 Qt 设计器在 python 中构建了一个应用程序,其中我添加了一个 matplotlibWidget 到窗口 main_plot_container 并将 NavigationToolbar2QT 添加到位于


在 python 中更新 matplotlib 后,“QuadContourSet”对象的属性没有设置器错误

我编写并运行了一个 cod 来绘制 netcdf 文件。升级 pip 和使用的库后,我收到错误:“QuadContourSet”对象的属性没有设置器。 如果有人能帮助我,我将不胜感激...


如何通过循环文件名数组来扩展 HTML 表格?

我对 HTML 很陌生。我知道如何添加表格行和单元格,以及如何通过路径插入图像。现在我已经通过Python和matplotlib生成了一堆图形的图像文件,并对它们进行了排序...


Angular Material 2:修复多行错误消息

我在我的角度应用程序中使用角度材料2。当我的表单输入字段错误消息超过一行时,我遇到了问题。这是照片: 这是代码: 我在我的角度应用程序中使用角度材料 2。当我的表单输入字段错误消息超过一行时,我遇到了问题。这是照片: 这是代码: <md-error *ngIf="password.touched && password.invalid"> <span *ngIf="password.errors.required"> {{'PASSWORD_RECOVERY.FIELD_REQUIRED' | translate}} </span> <span *ngIf="password.errors.minlength || password.errors.maxlength"> {{'PASSWORD_RECOVERY.PASSWORD_LENGTH' | translate}} </span> <span *ngIf="password.errors.pattern"> {{'PASSWORD_RECOVERY.FOR_A_SECURE_PASSWORD' | translate}} </span> </md-error> 我通过阅读 github 了解到,这是 Angular 2 材料中的一个错误。有人通过自定义解决方法成功解决了这个问题吗? 问题是类为 .mat-form-field-subscript-wrapper 的元素是 position: absolute,所以它不占用实际空间。 按照 xumepadismal 在 github 上关于此问题的建议,您可以添加此 scss 作为解决我的问题的解决方法: // Workaround for https://github.com/angular/material2/issues/4580. mat-form-field .mat-form-field { &-underline { position: relative; bottom: auto; } &-subscript-wrapper { position: static; } } 它会转换静态 div 中的 .mat-form-field-subscript-wrapper 节点,并将 .mat-form-field-unterline 重新定位在输入字段之后。 正如材料 15 中在 github 讨论中提到的,可以通过将 subscriptSizing="dynamic" 添加到 mat-form-field 来解决问题。 要更改默认行为,您必须使用以下选项更新 angular.module.ts 提供程序: providers: [ { provide: MAT_FORM_FIELD_DEFAULT_OPTIONS, useValue: { subscriptSizing: 'dynamic' } } ] 这也可以在材料文档中找到 使用@mattia.corci提出的解决方案会导致错误消息被推到底部太多,从而在顶部留下不必要的空白空间。 使用 Tailwind CSS,这个解决方案对我来说适用于最新的 Angular 17: .mat-mdc-form-field { @apply w-full self-start; .mat-mdc-form-field-subscript-wrapper { @apply flex; .mat-mdc-form-field-error-wrapper { @apply static; } } } mat-form-field.ng-invalid.ng-touched { animation: example; animation-duration: 0.3s; margin-bottom: 20px; } @keyframes example { from { margin-bottom: 0; } to { margin-bottom: 20px; } } 它对我有用。


按照路径流对 svg 填充进行动画处理

我有以下SVG;它类似于字母“P”。我想用黑色填充整个“P”,但要逐渐地遵循绘图的流程,就像正在绘制一样。 我有以下SVG;它类似于字母“P”。我想用黑色填充整个“P”,但要逐渐地遵循绘图的流程,就像正在绘制一样。 <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <g stroke="#000" stroke-width="1" fill="none"> <path d="M31.5294 14.2118C31.5294 18.8819 28.7623 22.9082 24.7793 24.7351C26.4612 23.3496 27.5322 21.248 27.5322 18.896C27.5322 14.7642 24.2259 11.4042 20.112 11.3205C20.0574 11.3167 20.0075 11.3167 19.9529 11.3167C19.8983 11.3167 19.8485 11.3167 19.7939 11.3205C18.2673 11.4033 17.0588 12.6663 17.0588 14.2108V28.6814C17.0588 33.4748 13.1699 37.3638 8.37646 37.3638V14.2118C8.37646 7.81928 13.5605 2.63528 19.9529 2.63528C26.3454 2.63528 31.5294 7.81928 31.5294 14.2118Z"/> </g> </svg> 如果我只是从下到上或从左到右填充,其他类似问题的解决方案,它不会遵循绘制时的“P”形状。请注意:我对 SVG 没有太多专业知识。 我举了一个例子来说明如何做到这一点。我知道这可能不完全是您想要的,但这说明了一条可以遵循的道路。 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <link rel="stylesheet" href="style.css"> </head> <body> <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <style> @keyframes fade-in-right { from { clip-path: circle(0px); } to { clip-path: circle(40px); } } #path2 { animation: fade-in-right ease 4s infinite; } </style> <g stroke="#000000" stroke-width="1" fill="none" id="g1"> <path d="m 31.5294,14.2118 c 0,4.6701 -2.7671,8.6964 -6.7501,10.5233 1.6819,-1.3855 2.7529,-3.4871 2.7529,-5.8391 0,-4.1318 -3.3063,-7.4918 -7.4202,-7.5755 -0.0546,-0.0038 -0.1045,-0.0038 -0.1591,-0.0038 -0.0546,0 -0.1044,0 -0.159,0.0038 -1.5266,0.0828 -2.7351,1.3458 -2.7351,2.8903 v 14.4706 c 0,4.7934 -3.8889,8.6824 -8.68234,8.6824 v -23.152 c 0,-6.39252 5.18404,-11.57652 11.57644,-11.57652 6.3925,0 11.5765,5.184 11.5765,11.57652 z" id="path1" /> </g> <g stroke="#000000" stroke-width="1" fill="none" id="g2"> <path d="m 31.5294,14.2118 c 0,4.6701 -2.7671,8.6964 -6.7501,10.5233 1.6819,-1.3855 2.7529,-3.4871 2.7529,-5.8391 0,-4.1318 -3.3063,-7.4918 -7.4202,-7.5755 -0.0546,-0.0038 -0.1045,-0.0038 -0.1591,-0.0038 -0.0546,0 -0.1044,0 -0.159,0.0038 -1.5266,0.0828 -2.7351,1.3458 -2.7351,2.8903 v 14.4706 c 0,4.7934 -3.8889,8.6824 -8.68234,8.6824 v -23.152 c 0,-6.39252 5.18404,-11.57652 11.57644,-11.57652 6.3925,0 11.5765,5.184 11.5765,11.57652 z" id="path2" style="fill:#000000;fill-opacity:1;stroke:none" /> </g> </svg> </body> </html>


© www.soinside.com 2019 - 2024. All rights reserved.