任何人都可以帮我用matplotlib设置固定位置的刻度线吗?我尝试过使用FixedPosition,因为本教程描述了:
ax = pl.gca()
ax.xaxis.set_major_locator(eval(locator))
Run Code Online (Sandbox Code Playgroud)
http://scipy-lectures.github.io/intro/matplotlib/matplotlib.html#figures-subplots-axes-and-ticks
但是当我尝试运行时,它告诉我set_major_locator方法不存在.
一个简单的例子非常有用.
谢谢.
我有以下代码:
@Service
public class MyService implements IMyService {
@Inject
IAnotherService anotherService;
// injects go here
// some code
@Transactional(isolation=Isolation.SERIALIZABLE)
public Result myMethod() {
// stuff done here
return this.myPrivateMethod()
}
private Result myPrivateMethod() {
// stuff done here
// multiple DAO SAVE of anObject
anotherService.processSomething(anObject);
return result;
}
}
@Service
public class AnotherService implements IAnotherService {
// injections here
// other stuff
@Transactional(isolation=SERIALIZABLE)
public Result processSomething(Object anObject) {
// some code here
// multiple dao save
// manipulation of anObject …Run Code Online (Sandbox Code Playgroud) 我有以下依赖项:A、B 和 X。“->”表示依赖。
A -> B
X -> A
Run Code Online (Sandbox Code Playgroud)
B 有以下公共类:
public class PublicClassB {
public static void do() {
}
}
Run Code Online (Sandbox Code Playgroud)
PublicClassB由 X 和 AE 使用
A 类的 pom 如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.company.name</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>my.company.name</groupId>
<artifactId>B</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
X 的 pom 如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>my.company.name</groupId>
<artifactId>X</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>my.company.name</groupId>
<artifactId>A</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
有没有办法从 X访问PublicClassB#do() ?我无法进行导入,Eclipse 没有检测到 B 上的包。
鉴于此示例代码:
public class MyServiceImpl implements MyService {
@Transactional
public void myTransactionalMethod() {
List<Item> itemList = itemService.findItems();
for (Item anItem : itemList) {
try {
processItem(anItem);
catch (Exception e) {
// dont rollback here
// rollback just one item
}
}
}
@Transactional
public void processItem(Item anItem) {
anItem.setSomething(new Something);
anItem.applyBehaviour();
itemService.save(anItem);
}
}
Run Code Online (Sandbox Code Playgroud)
这是我想要实现的目标:
processItem(anItem);在其中发生异常时才应回滚.myTransactionalMethod应该继续,这意味着for-each应该结束.myTransactionalMethod但不在内processItem(anItem),myTransactionalMethod则应完全回滚.是否存在不涉及手动管理事务(没有注释)的解决方案?
编辑:我正在考虑使用@Transactional(PROPAGATION=REQUIRES_NEW),不知道它是否会在同一个bean中工作.
我想过滤一个这样的字符串:'Hello%World'----> List = ['Hello','World']有没有内置函数?
我试图在pygame屏幕上创建一个透明的表面,遗憾的是无法正常工作.主表面显示确定,但我试图生成的表面根本没有显示.
import pygame as pg
from pygame.locals import *
pg.display.init()
h = 640
w = 480
_display = pg.display.set_mode((h,w))
_display.fill(pg.Color(0,0,0))
_active_surface = pg.Surface((h,w))
#_active_surface.set_colorkey((255,0,255))
_active_surface.fill(pg.Color(255,0,255))
_display.blit(_active_surface, (h,w))
while True:
for i in pg.event.get():
if i.type == QUIT:
pg.quit()
pg.display.flip()
Run Code Online (Sandbox Code Playgroud) 任何人都知道如何使用值作为参考对列表进行排序?例如,我有以下列表:
1,3,5,10,12
Run Code Online (Sandbox Code Playgroud)
和单个值7,输出将是:
5,10,3,12,1
Run Code Online (Sandbox Code Playgroud)
谢谢!
python ×4
java ×3
list ×2
spring ×2
dependencies ×1
hibernate ×1
isolation ×1
matplotlib ×1
maven ×1
pom.xml ×1
pygame ×1
sorting ×1
string ×1
transactions ×1